[Checkins] SVN: z3c.testsetup/branches/multani-patches/src/z3c/testsetup/ Detect tests which are in __init__.py files
Jonathan Ballet
jon at multani.info
Thu Dec 16 04:16:53 EST 2010
Log message for revision 118945:
Detect tests which are in __init__.py files
Changed:
U z3c.testsetup/branches/multani-patches/src/z3c/testsetup/doctesting.py
A z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/
A z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/__init__.py
A z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/initsetup01.py
U z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions.txt
-=-
Modified: z3c.testsetup/branches/multani-patches/src/z3c/testsetup/doctesting.py
===================================================================
--- z3c.testsetup/branches/multani-patches/src/z3c/testsetup/doctesting.py 2010-12-16 09:14:31 UTC (rev 118944)
+++ z3c.testsetup/branches/multani-patches/src/z3c/testsetup/doctesting.py 2010-12-16 09:16:53 UTC (rev 118945)
@@ -83,9 +83,16 @@
if os.path.isabs(name):
# We get absolute pathnames, but we need relative ones...
- common_prefix = os.path.commonprefix([self.package.__file__,
+
+ if os.path.basename(name).startswith('__init__.py'):
+ # The file we are currently trying to test is the
+ # __init__.py of package. Don't try tp reduce its name
+ # further than '__init__.py', or we will get an empty name.
+ name = '__init__.py'
+ else:
+ common_prefix = os.path.commonprefix([self.package.__file__,
name])
- name = name[len(common_prefix):]
+ name = name[len(common_prefix):]
suite_creator = doctest.DocFileSuite
if functional_zcml_layer is not None:
Added: z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/__init__.py
===================================================================
--- z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/__init__.py (rev 0)
+++ z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/__init__.py 2010-12-16 09:16:53 UTC (rev 118945)
@@ -0,0 +1,8 @@
+"""
+
+.. :doctest:
+
+>>> print "foo"
+foo
+
+"""
Added: z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/initsetup01.py
===================================================================
--- z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/initsetup01.py (rev 0)
+++ z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions/tests_in_init/initsetup01.py 2010-12-16 09:16:53 UTC (rev 118945)
@@ -0,0 +1,3 @@
+from z3c.testsetup import register_all_tests
+name = 'z3c.testsetup.tests.regressions.tests_in_init'
+test_suite = register_all_tests(name)
Modified: z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions.txt
===================================================================
--- z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions.txt 2010-12-16 09:14:31 UTC (rev 118944)
+++ z3c.testsetup/branches/multani-patches/src/z3c/testsetup/tests/regressions.txt 2010-12-16 09:16:53 UTC (rev 118945)
@@ -35,3 +35,25 @@
Tearing down left over layers:
Tear down z3c.testsetup.functional.layer.DefaultZCMLLayer [/COMPONENT/tests/regressions/norm_zcml_layers/layer.zcml] ... not supported
False
+
+
+__init__.py tests
+=================
+
+Be sure to launch the tests which are in a ``__init__.py`` file:
+
+ >>> path = os.path.join(REG_TESTS, 'tests_in_init')
+ >>> defaults = [
+ ... '--path', path,
+ ... '--tests-pattern', '^initsetup01$', '-vvvv',
+ ... ]
+ >>> testrunner.run(defaults)
+ Running tests at level 1
+ Running zope.testing.testrunner.layer.UnitTests tests:
+ Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ Running:
+ /COMPONENT/tests/regressions/tests_in_init/__init__.py (... s)
+ Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+ Tearing down left over layers:
+ Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+ False
More information about the checkins
mailing list