[Checkins] SVN: grokproject/trunk/tests.py Test setup cleanup.

Jan-Jaap Driessen jdriessen at thehealthagency.com
Wed Feb 2 05:28:41 EST 2011


Log message for revision 120043:
  Test setup cleanup.

Changed:
  U   grokproject/trunk/tests.py

-=-
Modified: grokproject/trunk/tests.py
===================================================================
--- grokproject/trunk/tests.py	2011-02-02 10:06:38 UTC (rev 120042)
+++ grokproject/trunk/tests.py	2011-02-02 10:28:40 UTC (rev 120043)
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
 """
 Grabs the tests in doctest
 
@@ -13,9 +12,8 @@
 import sys
 import tempfile
 import unittest
+import doctest
 
-from zope.testing import doctest
-
 CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
 SHORTTESTFILE = os.path.join(os.path.dirname(__file__), 'shorttests')
 
@@ -61,10 +59,6 @@
     else:
         print 'No file named %s' % filename
 
-def touch(*args, **kwargs):
-    filename = os.path.join(*args)
-    open(filename, 'w').write(kwargs.get('data',''))
-
 def shorttests():
     return os.path.exists(SHORTTESTFILE)
 
@@ -89,41 +83,7 @@
     maybe_rmdir(test.globs['eggsdir'])
     shutil.rmtree(test.globs['testdir'])
 
-def doc_suite(package_dir):
-    """Returns a test suite"""
-    suite = []
-    flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
-             doctest.REPORT_ONLY_FIRST_FAILURE)
 
-    if package_dir not in sys.path:
-        sys.path.append(package_dir)
-
-    tests = [os.path.join(package_dir, filename)
-            for filename in [
-                'tests_paste.txt',
-                ]]
-    globs = {
-        'ls': ls,
-        'cd': cd,
-        'cat': cat,
-        'touch': touch,
-        'sh': sh,
-        'read_sh': read_sh,
-        'current_dir': CURRENT_DIR,
-        }
-
-    for test in tests:
-        suite.append(
-            doctest.DocFileSuite(
-                test,
-                optionflags=flags,
-                globs=globs,
-                setUp=setup,
-                tearDown=teardown,
-                module_relative=False
-                ))
-    return unittest.TestSuite(suite)
-
 def show_shorttests_message():
     if shorttests():
         print
@@ -147,9 +107,24 @@
         print
 
 def test_suite():
-    """returns the test suite"""
     show_shorttests_message()
-    return doc_suite(CURRENT_DIR)
 
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+    globs = {
+        'ls': ls,
+        'cd': cd,
+        'cat': cat,
+        'sh': sh,
+        'read_sh': read_sh,
+        'current_dir': CURRENT_DIR,
+        }
+
+    suite = []
+    suite.append(
+        doctest.DocFileSuite(
+            'tests_paste.txt',
+            optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE,
+            globs=globs,
+            setUp=setup,
+            tearDown=teardown,
+            ))
+    return unittest.TestSuite(suite)



More information about the checkins mailing list