[Checkins] SVN: z3c.testsetup/branches/new_markers/src/z3c/testsetup/testing.py Use marker functions for detecting marker strings.
Uli Fouquet
uli at gnufix.de
Wed Jan 7 08:52:43 EST 2009
Log message for revision 94575:
Use marker functions for detecting marker strings.
Changed:
U z3c.testsetup/branches/new_markers/src/z3c/testsetup/testing.py
-=-
Modified: z3c.testsetup/branches/new_markers/src/z3c/testsetup/testing.py
===================================================================
--- z3c.testsetup/branches/new_markers/src/z3c/testsetup/testing.py 2009-01-07 13:20:09 UTC (rev 94574)
+++ z3c.testsetup/branches/new_markers/src/z3c/testsetup/testing.py 2009-01-07 13:52:43 UTC (rev 94575)
@@ -17,7 +17,8 @@
import re
from martian.scan import module_info_from_dotted_name
from z3c.testsetup.base import BasicTestSetup
-from z3c.testsetup.util import get_package
+from z3c.testsetup.util import (get_package, get_marker_from_string,
+ get_marker_from_file)
class UnitTestSetup(BasicTestSetup):
"""A unit test setup for packages.
@@ -36,12 +37,13 @@
"""
regexp_list = [
- '^((\.\.\s+)?:unittest:(.*))|(\s*:(T|t)est-(L|l)ayer:\s*(python)\s*)',
+ '^\s*:(T|t)est-(L|l)ayer:\s*(python)\s*',
]
-
+
def __init__(self, package, pfilter_func=None, regexp_list=None):
BasicTestSetup.__init__(self, package, regexp_list=regexp_list)
self.pfilter_func = pfilter_func or self.isTestModule
+ self.filter_func = self.pfilter_func
def docstrContains(self, docstr, regexp_list):
"""Does a docstring contain lines matching every of the regular
@@ -50,6 +52,8 @@
found_list = []
if docstr is None:
return False
+ if get_marker_from_string('unittest', docstr) is not None:
+ return True
for line in docstr.split('\n'):
for regexp in regexp_list:
if re.compile(regexp).match(line) and (
@@ -69,7 +73,8 @@
# Do not even try to load modules, that have no marker string.
if not self.fileContains(
module_info.path, self.regexp_list):
- return False
+ if get_marker_from_file('unittest', module_info.path) is None:
+ return False
module = None
try:
module = module_info.getModule()
More information about the Checkins
mailing list