def test_suite(): """.""" setup_site() return ts( __file__, #patterns = ['(handl|basic).*txt$'], patterns=['.*txt$'], globs=globals(), testklass=FunctionalTestCase)
def test_suite(): """.""" setup_site() return ts( __file__, #patterns = ['(handl|basic).*txt$'], patterns = ['.*txt$'], globs=globals(), testklass=FunctionalTestCase )
def test_doctests_suite(directory=__file__, files=None, patterns=None, globs=None, suite=None, testklass=None, doctest_options=doctest_flags, lsetUp=None, ltearDown=None): """A doctest suite launcher. You can even launch doctests from others packages with the csvreplicata setup with embedding this test suite You can even add others globals in those tests. No need to copy and duplicate this file, it is useless. #Example : This snippet will launch all txt doctests in the other package directory >>> from Products.csvreplicata.tests.test_setup import test_doctests_suite as ts >>> def test_suite(): ... globs = globals() ... return ts(__file__, globs) directory: where to find files to test globs: A dictionnary to setup test globals from. directory: directory or filename where to run the tests files: files to include pattern: pattern for tests inclusion in the suite suite: a TestSuite object testklass: only useful if you are inside a Zope2 environment, because ztc comes from there. Note that in this case, setUp and tearDown are useless. Indeed modern application relys more on the setUp and tearDown functions. tearDown: tearDown code to run setUp: setUp code to run """ _f = None if not patterns: patterns = ['.txt$'] if not directory or os.path.isfile(directory): directory, _f = os.path.split(os.path.abspath(directory)) elif os.path.isfile(directory): directory = os.path.dirname(directory) if not globs: globs = {} g = globals() for key in g: globs.setdefault(key, g[key]) if not files: files = [ os.path.join(directory, f) for f in os.listdir(directory) if testfilter(patterns, f) ] else: for i, f in enumerate(files[:]): if not os.path.sep in f: files[i] = os.path.abspath(os.path.join(directory, f)) else: files[i] = os.path.abspath(f) if not suite: suite = unittest.TestSuite() if files: for test in files: ft = None if HAS_ZOPE2: if not testklass: testklass = DocTestCase ft = ztc.FunctionalDocFileSuite( test, test_class=testklass, optionflags=doctest_options, globs=globs, module_relative=False, ) else: if lsetUp: setUp = lsetUp if ltearDown: tearDown = ltearDown ft = doctest.DocFileSuite( test, optionflags=doctest_options, globs=globs, setUp=setUp, tearDown=tearDown, module_relative=False, ) if ft: suite.addTest(ft) return suite
def test_doctests_suite(directory=__file__, files = None, patterns = None, globs=None, suite=None, testklass=None, doctest_options = doctest_flags, lsetUp=None, ltearDown=None ): """A doctest suite launcher. You can even launch doctests from others packages with the csvreplicata setup with embedding this test suite You can even add others globals in those tests. No need to copy and duplicate this file, it is useless. #Example : This snippet will launch all txt doctests in the other package directory >>> from Products.csvreplicata.tests.test_setup import test_doctests_suite as ts >>> def test_suite(): ... globs = globals() ... return ts(__file__, globs) directory: where to find files to test globs: A dictionnary to setup test globals from. directory: directory or filename where to run the tests files: files to include pattern: pattern for tests inclusion in the suite suite: a TestSuite object testklass: only useful if you are inside a Zope2 environment, because ztc comes from there. Note that in this case, setUp and tearDown are useless. Indeed modern application relys more on the setUp and tearDown functions. tearDown: tearDown code to run setUp: setUp code to run """ _f = None if not patterns: patterns = ['.txt$'] if not directory or os.path.isfile(directory): directory, _f = os.path.split(os.path.abspath(directory)) elif os.path.isfile(directory): directory = os.path.dirname(directory) if not globs: globs={} g = globals() for key in g: globs.setdefault(key, g[key]) if not files: files = [os.path.join(directory, f) for f in os.listdir(directory) if testfilter(patterns, f)] else: for i, f in enumerate(files[:]): if not os.path.sep in f: files[i] = os.path.abspath(os.path.join(directory, f)) else: files[i] = os.path.abspath(f) if not suite: suite = unittest.TestSuite() if files: for test in files: ft = None if HAS_ZOPE2: if not testklass: testklass=DocTestCase ft = ztc.FunctionalDocFileSuite( test, test_class=testklass, optionflags=doctest_options, globs=globs, module_relative = False, ) else: if lsetUp: setUp=lsetUp if ltearDown: tearDown=ltearDown ft = doctest.DocFileSuite( test, optionflags=doctest_options, globs=globs, setUp=setUp, tearDown=tearDown, module_relative = False, ) if ft: suite.addTest(ft) return suite