[Checkins] SVN: z3c.testsetup/trunk/src/z3c/testsetup/test Set up layered setup tests with ZCML layers allowed to be torn down. This way we (hopefully) make the Windows tests

Uli Fouquet uli at gnufix.de
Tue Sep 14 19:31:35 EDT 2010


Log message for revision 116421:
  Set up layered setup tests with ZCML layers allowed to be torn down. This way we (hopefully) make the Windows tests 
  pass again. While the tests defined in the layered testsetup do not need to be run in separated subprocesses, this
  might be an issue in real-world applications. But it seems not to be something we can handle inside z3c.testsetup.
  
  

Changed:
  U   z3c.testsetup/trunk/src/z3c/testsetup/testrunner.txt
  U   z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layeredsetup01.py

-=-
Modified: z3c.testsetup/trunk/src/z3c/testsetup/testrunner.txt
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/testrunner.txt	2010-09-14 15:31:20 UTC (rev 116420)
+++ z3c.testsetup/trunk/src/z3c/testsetup/testrunner.txt	2010-09-14 23:31:34 UTC (rev 116421)
@@ -551,7 +551,7 @@
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Using z3c.testsetup, we can define quite complex testsetups with only
-two lines of code::
+three lines of code::
 
     >>> import os
     >>> import z3c.testsetup
@@ -560,12 +560,14 @@
     >>> setupfile = os.path.join(cavepath, 'layeredsetup01.py')
     >>> print open(setupfile).read()
     from z3c.testsetup import register_all_tests
-    test_suite = register_all_tests('z3c.testsetup.tests.layered_cave')
+    test_suite = register_all_tests('z3c.testsetup.tests.layered_cave',
+                                    allow_teardown=True)
 
 This means, that we want to register all tests (doctests and 'normal'
-python tests) from the ``layered_cave`` package, whose name we passed in
-dotted name notation as a string. This is enough information for a
-testrunner.
+python tests) from the ``layered_cave`` package, whose name we passed
+in dotted name notation as a string. We also want the functional tests
+to be torn down after running each doctest file to make the tests pass
+also on Windows. This is enough information for a testrunner.
 
 In one of the test files we declared, that a layer should be used::
 
@@ -602,28 +604,26 @@
     ...     '--tests-pattern', '^layeredsetup01$',
     ...     ]
     >>> testrunner.run(defaults)
-    Running z3c....DefaultZCMLLayer [.../bar/ftesting.zcml] tests:
-      Set up z3c....DefaultZCMLLayer [.../bar/ftesting.zcml] in 0.027 seconds.
-      Ran 1 tests with 0 failures and 0 errors in 0.002 seconds.
-    Running z3c....DefaultZCMLLayer [.../foo/ftesting.zcml] tests:
-      Tear down z3c....DefaultZCMLLayer [.../bar/ftesting.zcml] ... not supported
-      Running in a subprocess.
-      Set up z3c....DefaultZCMLLayer [.../foo/ftesting.zcml] in 0.055 seconds.
-      Ran 1 tests with 0 failures and 0 errors in 0.015 seconds.
-      Tear down z3c....DefaultZCMLLayer [.../foo/ftesting.zcml] ... not supported
-    Running z3c....FunctionalLayer1 tests:
-      Running in a subprocess.
-      Set up z3c....FunctionalLayer1 in 0.040 seconds.
-      Ran 1 tests with 0 failures and 0 errors in 0.011 seconds.
-      Tear down z3c....FunctionalLayer1 in 0.000 seconds.
-    Running z3c....UnitLayer1 tests:
-      Running in a subprocess.
-      Set up z3c....UnitLayer1 in 0.000 seconds.
+    Running z3c...DefaultZCMLLayer [/.../bar/ftesting.zcml] tests:
+      Set up z3c...DefaultZCMLLayer [/.../bar/ftesting.zcml] in N.NNN seconds.
+      Ran 1 tests with 0 failures and 0 errors in 0.003 seconds.
+    Running z3c.testsetup...DefaultZCMLLayer [/.../foo/ftesting.zcml] tests:
+      Tear down z3c...DefaultZCMLLayer [/.../bar/ftesting.zcml] in N.NNN seconds.
+      Set up z3c...DefaultZCMLLayer [/.../foo/ftesting.zcml] in N.NNN seconds.
+      Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+    Running z3c...layer.FunctionalLayer1 tests:
+      Tear down z3c...DefaultZCMLLayer [/.../foo/ftesting.zcml] in N.NNN seconds.
+      Set up z3c...FunctionalLayer1 in N.NNN seconds.
+    Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+    Running z3c.testsetup.tests.layered_cave.layer.UnitLayer1 tests:
+      Tear down z3c...FunctionalLayer1 in N.NNN seconds.
+      Set up z3c.testsetup.tests.layered_cave.layer.UnitLayer1 in N.NNN seconds.
         Running testSetUp of UnitLayer1
         Running testTearDown of UnitLayer1
-      Ran 1 tests with 0 failures and 0 errors in 0.010 seconds.
-      Tear down z3c....UnitLayer1 in 0.000 seconds.
-    Total: 4 tests, 0 failures, 0 errors in 6.014 seconds.
+      Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+    Tearing down left over layers:
+    Tear down z3c...UnitLayer1 in N.NNN seconds.
+    Total: 4 tests, 0 failures, 0 errors in N.NNN seconds.
     False
 
 As we can see, the layer `UnitLayer1` was executed here.

Modified: z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layeredsetup01.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layeredsetup01.py	2010-09-14 15:31:20 UTC (rev 116420)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/layered_cave/layeredsetup01.py	2010-09-14 23:31:34 UTC (rev 116421)
@@ -1,2 +1,3 @@
 from z3c.testsetup import register_all_tests
-test_suite = register_all_tests('z3c.testsetup.tests.layered_cave')
+test_suite = register_all_tests('z3c.testsetup.tests.layered_cave',
+                                allow_teardown=True)



More information about the checkins mailing list