[Checkins] SVN: z3c.testsetup/branches/new_markers/src/z3c/testsetup/tests/test_testsetup.py Add test method to prevent expected output to be grabbed as tests.

Uli Fouquet uli at gnufix.de
Tue Jan 6 14:31:47 EST 2009


Log message for revision 94548:
  Add test method to prevent expected output to be grabbed as tests.

Changed:
  U   z3c.testsetup/branches/new_markers/src/z3c/testsetup/tests/test_testsetup.py

-=-
Modified: z3c.testsetup/branches/new_markers/src/z3c/testsetup/tests/test_testsetup.py
===================================================================
--- z3c.testsetup/branches/new_markers/src/z3c/testsetup/tests/test_testsetup.py	2009-01-06 15:55:17 UTC (rev 94547)
+++ z3c.testsetup/branches/new_markers/src/z3c/testsetup/tests/test_testsetup.py	2009-01-06 19:31:46 UTC (rev 94548)
@@ -48,8 +48,20 @@
     basenames = [os.path.basename(x) for x in get_filenames_from_suite(suite)]
     basenames.sort()
     return basenames
-    
 
+def print_file(path):
+    """Prints file contents with leading bar on each line.
+
+    This way we prevent the testrunner to test the output.
+    """
+    contents = open(path, 'r').read()
+    print '|  ' + '\n|  '.join(contents.split('\n'))
+    return
+    print 
+    contents = contents.split('\n')
+    return '\n|'.join(contents)
+    return
+
 def setUpZope(test):
     zope.component.eventtesting.setUp(test)
 
@@ -69,6 +81,7 @@
         test.globs['this_directory'] = os.path.split(__file__)[0]
         test.globs['testrunner_script'] = __file__
         test.globs['get_basenames_from_suite'] = get_basenames_from_suite
+        test.globs['print_file'] = print_file
 
     def tearDown(test):
         sys.path[:], sys.argv[:] = test.globs['saved-sys-info'][:2]
@@ -133,7 +146,8 @@
                                 tearDown=cleanUpZope,
                                 globs={'pnorm':pnorm,
                                        'get_basenames_from_suite':
-                                       get_basenames_from_suite},
+                                       get_basenames_from_suite,
+                                       'print_file':print_file,},
                                 checker=checker,
                                 optionflags=doctest.ELLIPSIS+
                                 doctest.NORMALIZE_WHITESPACE)



More information about the Checkins mailing list