def __init__(self, doctest=pythondoctest, patterns=()): RENormalizing.__init__(self, patterns) self.doctest = doctest # make sure these optionflags are registered doctest.register_optionflag('PARSE_HTML') doctest.register_optionflag('PARSE_XML') doctest.register_optionflag('NOPARSE_MARKUP')
def test_suite(): this = sys.modules[__name__] suite = unittest.defaultTestLoader.loadTestsFromModule(this) checker = RENormalizing([ (re.compile(r'object at 0x[0-9a-fA-F]+'), 'object at 0xXXXXXXX'), (re.compile(r'\btid[0-9xA-Fa-f]+'), 'tidXXXXXXXXXXXXXXXXXX'), (re.compile(r'\btid=[0-9xA-Fa-f]+'), 'tid=XXXXXXXXXXXXXXXXXX'), (re.compile(r'\boid=[0-9xA-Fa-f]+'), 'oid=XX'), (re.compile(r'\boid [0-9xA-Fa-f]+'), 'oid XX'), (re.compile(r'\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d[.]\d\d\d\d\d\d'), 'YYYY-MM-DD HH:MM:SS.SSSSSS'), (re.compile(r'\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d'), 'YYYY-MM-DD HH:MM:SS'), # zope.app.folder.folder.Folder was moved to zope.site.folder.Folder # but we still support ancient zope versions here (re.compile(r'zope\.app\.folder\.folder\.Folder'), 'zope.site.folder.Folder'), # zope.container 4.0.0 made Folder objects inherit from BTreeContainer # this adds one new attribute that our tests don't expect to see (re.compile(r'<strong>_BTreeContainer__len</strong>'), ''), # Python 3 has unicode strings without u prefixes (re.compile(r"u('.*')"), r'\1'), (re.compile(r": u'$", re.MULTILINE), ": '"), ]) optionflags = (doctest.REPORT_ONLY_FIRST_FAILURE | doctest.REPORT_NDIFF | doctest.NORMALIZE_WHITESPACE) here = os.path.dirname(__file__) for filename in sorted(glob.glob(os.path.join(here, '*.txt'))): test = doctest.DocFileSuite(os.path.basename(filename), setUp=setUp, checker=checker, optionflags=optionflags) test.layer = TestsWithServer suite.addTest(test) return suite
def test_suite(): suite = unittest.TestSuite() flags = (doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS) checker = RENormalizing([ # python 3 drops the u" prefix on unicode strings (re.compile(r"u('[^']*')"), r"\1"), # python 3 includes module name in exceptions (re.compile(r"crate.client.exceptions.ProgrammingError:"), "ProgrammingError:"), (re.compile(r"crate.client.exceptions.ConnectionError:"), "ConnectionError:"), (re.compile(r"crate.client.exceptions.DigestNotFoundException:"), "DigestNotFoundException:"), (re.compile(r"crate.client.exceptions.BlobsDisabledException:"), "BlobsDisabledException:"), (re.compile(r"<type "), "<class "), ]) # DJANGO TESTS django_suite = doctest.DocFileSuite('testing/backend.txt', checker=checker, setUp=setUpForDjango, optionflags=flags) django_suite.layer = crate_layer suite.addTest(django_suite) return suite
def test_suite(): from unittest import TestSuite, makeSuite import doctest optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS checker = RENormalizing([ # Python 3 includes module name in exceptions (re.compile(r"sqlalchemy.orm.exc.DetachedInstanceError:"), "DetachedInstanceError:"), # Python 3 drops the u'' prefix on unicode strings (re.compile(r"u('[^']*')"), r"\1"), # PyPy includes __builtin__ in front of classes defined in doctests (re.compile(r"__builtin__[.]Address"), "Address"), ]) suite = TestSuite() suite.addTest(makeSuite(ZopeSQLAlchemyTests)) suite.addTest(makeSuite(MultipleEngineTests)) if TEST_DSN.startswith('postgres') or TEST_DSN.startswith('oracle'): suite.addTest(makeSuite(RetryTests)) suite.addTest( doctest.DocFileSuite('README.txt', optionflags=optionflags, checker=checker, tearDown=tearDownReadMe, globs={ 'TEST_DSN': TEST_DSN, 'TEST_TWOPHASE': TEST_TWOPHASE })) return suite
def test_suite(): suite = unittest.TestSuite() for class_ in ( FileStorageZlibTests, FileStorageZlibTestsWithBlobsEnabled, FileStorageZlibRecoveryTest, FileStorageZEOZlibTests, FileStorageClientZlibZEOZlibTests, FileStorageClientZlibZEOServerZlibTests, ): s = unittest.makeSuite(class_, "check") s.layer = ZODB.tests.util.MininalTestLayer('zlibstoragetests.%s' % class_.__name__) suite.addTest(s) suite.addTest(unittest.makeSuite(TestIterator)) suite.addTest(unittest.makeSuite(TestServerZlibStorage)) # The conflict resolution and blob tests don't exercise proper # plumbing for zlibstorage because the sample data they use # compresses to larger than the original. Run the tests again # after monkey patching zlibstorage to compress everything. class ZLibHackLayer: orig = [zc.zlibstorage.compress] # []s hide the function :) @classmethod def setUp(self): zc.zlibstorage.transform = (lambda data: data and (b'.z' + zlib.compress(data)) or data) @classmethod def tearDown(self): [zc.zlibstorage.compress] = self.orig s = unittest.makeSuite(FileStorageZlibTestsWithBlobsEnabled, "check") s.layer = ZLibHackLayer suite.addTest(s) checker = RENormalizing([ # Py3k renders bytes where Python2 used native strings... (re.compile(r"b'"), "'"), (re.compile(r'b"'), '"'), # Older versions of PyPy2 (observed in PyPy2 5.4 but not 5.6) # produce long integers (1L) where we expect normal ints (re.compile(r"(\d)L"), r"\1") ]) suite.addTest( doctest.DocTestSuite(checker=checker, setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown)) suite.addTest( manuel.testing.TestSuite(manuel.doctest.Manuel() + manuel.capture.Manuel(), 'README.txt', setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown)) return suite
def test_suite(): checker = RENormalizing([ # Python 3 includes module name in exceptions (re.compile(r"zope.publisher.interfaces.NotFound"), "NotFound"), ]) return unittest.TestSuite((DocTestSuite('zope.publisher.browser', checker=checker), ))
def test_suite(): checker = RENormalizing([ # Python 3 includes module name in exceptions (re.compile(r"__builtin__"), "builtins"), ]) return unittest.TestSuite( doctest.DocFileSuite('../skinnable.txt', setUp=cleanUp, tearDown=cleanUp, checker=checker))
def test_suite(): checker = RENormalizing([ # Python 3 includes module name in exceptions (re.compile(r"zope.location.interfaces.LocationError"), "LocationError" ), ]) return DocTestSuite('zope.traversing.namespace', setUp=setUp, tearDown=tearDown, checker=checker)
def test_suite(): checker = RENormalizing([ # Python 3 includes module name in exceptions (re.compile(r"zope.publisher.interfaces.NotFound"), "NotFound"), ]) return unittest.TestSuite((doctest.DocTestSuite( 'zope.browserresource.resources', setUp=setUp, tearDown=tearDown, checker=checker, optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE), ))
def test_suite(): checker = RENormalizing([ # Python 3 includes module name in exceptions (re.compile(r"zope.location.interfaces.LocationError"), "LocationError" ), ]) suite = unittest.defaultTestLoader.loadTestsFromName(__name__) suite.addTest( DocTestSuite('zope.traversing.namespace', setUp=setUp, tearDown=tearDown, checker=checker)) return suite
def test_suite(): suite = unittest.TestSuite() checker = RENormalizing([ (re.compile(r"u('[^']*')"), r"\1"), (re.compile(r"<type "), "<class "), ]) s = doctest.DocFileSuite('layer.txt', setUp=setUp, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=checker, encoding='utf-8') suite.addTest(s) suite.addTest(unittest.makeSuite(LayerUtilsTest)) return suite
def test_suite(): checker = RENormalizing([ # Python 3 includes module name in exceptions (re.compile(r"zope.security.interfaces.ForbiddenAttribute"), "ForbiddenAttribute"), (re.compile(r"<class 'zope.security._proxy._Proxy'>"), "<type 'zope.security._proxy._Proxy'>"), (re.compile(r"<class 'list'>"), "<type 'list'>"), # PyPy/pure-Python implementation (re.compile(r"<class 'zope.security.proxy.ProxyPy'>"), "<type 'zope.security._proxy._Proxy'>"), ]) suite = unittest.defaultTestLoader.loadTestsFromName(__name__) suite.addTest( doctest.DocTestSuite('zope.pagetemplate.engine', checker=checker)) return suite
def test_suite(): checker = RENormalizing(( (re.compile("u'(.*)'"), "'\\1'"), (re.compile('u"(.*)"'), '"\\1"'), (re.compile('zope.security.interfaces.Unauthorized'), 'Unauthorized'), )) return unittest.TestSuite(( doctest.DocFileSuite('README.txt', setUp=testing.setUp, tearDown=testing.tearDown, checker=checker, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS, ), doctest.DocFileSuite('sequence.txt', setUp=testing.setUp, tearDown=testing.tearDown, checker=checker, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS, ), doctest.DocFileSuite('sort.txt', setUp=testing.setUp, tearDown=testing.tearDown, checker=checker, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS, ), doctest.DocFileSuite('batch.txt', setUp=testing.setUp, tearDown=testing.tearDown, checker=checker, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS|doctest.REPORT_UDIFF, ), doctest.DocFileSuite('miscellaneous.txt', setUp=testing.setUp, tearDown=testing.tearDown, checker=checker, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS, ), doctest.DocFileSuite('column.txt', setUp=testing.setUp, tearDown=testing.tearDown, checker=checker, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS, ), unittest.makeSuite(TestTable), unittest.makeSuite(TestSequenceTable), unittest.makeSuite(TestColumn), unittest.makeSuite(TestNoneCell), unittest.makeSuite(TestNameColumn), unittest.makeSuite(TestRadioColumn), unittest.makeSuite(TestCheckBoxColumn), unittest.makeSuite(TestBatchProvider), ))
def test_suite(): checker = RENormalizing([ # Python 3 includes module name in exceptions (re.compile(r"zope.security.interfaces.ForbiddenAttribute"), "ForbiddenAttribute"), (re.compile(r"<class 'zope.security._proxy._Proxy'>"), "<type 'zope.security._proxy._Proxy'>"), (re.compile(r"<class 'list'>"), "<type 'list'>"), # PyPy/pure-Python implementation (re.compile(r"<class 'zope.security.proxy.ProxyPy'>"), "<type 'zope.security._proxy._Proxy'>"), ]) suite = unittest.TestSuite() suite.addTest( doctest.DocTestSuite('zope.pagetemplate.engine', checker=checker)) suite.addTest(unittest.makeSuite(EngineTests)) if zope.pagetemplate.engine.HAVE_UNTRUSTED: suite.addTest(unittest.makeSuite(ZopePythonExprTests)) return suite
def test_suite(): checker = RENormalizing([ # datetime is a class in Python 3, but a type in Python 2 (re.compile("<class 'datetime\.datetime'>"), "<type 'datetime.datetime'>"), # Python 3.2 adds quotes around the module name (re.compile("ImportError: No module named '([^']*)'"), r"ImportError: No module named \1"), # and improves the message in other ways too (re.compile(r"ImportError: No module named datetime\.foo;" " datetime is not a package"), "ImportError: No module named foo"), # PyPy 1.9 has some different error messages and reprs (re.compile(r"ImportError: No module named datetime\.foo"), "ImportError: No module named foo"), (re.compile( r"<bound method type\.now of <type 'datetime\.datetime'>>"), "<built-in method now of type object at ...>"), ]) return unittest.TestSuite((doctest.DocFileSuite(README, checker=checker, optionflags=FLAGS, module_relative=False), ))
def test_suite(): suite = unittest.TestSuite() flags = (doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS) checker = RENormalizing([ # python 3 drops the u" prefix on unicode strings (re.compile(r"u('[^']*')"), r"\1"), # python 3 includes module name in exceptions (re.compile(r"crate.client.exceptions.ProgrammingError:"), "ProgrammingError:"), (re.compile(r"crate.client.exceptions.ConnectionError:"), "ConnectionError:"), (re.compile(r"crate.client.exceptions.DigestNotFoundException:"), "DigestNotFoundException:"), (re.compile(r"crate.client.exceptions.BlobsDisabledException:"), "BlobsDisabledException:"), (re.compile(r"<type "), "<class "), ]) s = doctest.DocFileSuite('cursor.txt', 'connection.txt', checker=checker, setUp=setUpMocked, optionflags=flags) suite.addTest(s) suite.addTest(unittest.makeSuite(CursorTest)) suite.addTest(unittest.makeSuite(HttpClientTest)) suite.addTest(unittest.makeSuite(KeepAliveClientTest)) suite.addTest(unittest.makeSuite(ThreadSafeHttpClientTest)) suite.addTest(unittest.makeSuite(ParamsTest)) suite.addTest(unittest.makeSuite(ConnectionTest)) suite.addTest(sqlalchemy_test_suite()) suite.addTest(doctest.DocTestSuite('crate.client.connection')) suite.addTest(doctest.DocTestSuite('crate.client.http')) s = doctest.DocFileSuite('../../../docs/https.txt', checker=checker, setUp=setUpWithHttps, optionflags=flags) s.layer = HttpsTestServerLayer() suite.addTest(s) s = doctest.DocFileSuite('sqlalchemy/itests.txt', 'sqlalchemy/dialect.txt', checker=checker, setUp=setUpCrateLayerAndSqlAlchemy, tearDown=tearDownWithCrateLayer, optionflags=flags) s.layer = crate_layer suite.addTest(s) s = doctest.DocFileSuite('http.txt', 'blob.txt', '../../../docs/client.txt', '../../../docs/advanced_usage.txt', '../../../docs/blobs.txt', checker=checker, setUp=setUpWithCrateLayer, tearDown=tearDownWithCrateLayer, optionflags=flags) s.layer = crate_layer suite.addTest(s) s = doctest.DocFileSuite('../../../docs/sqlalchemy.txt', checker=checker, setUp=setUpCrateLayerAndSqlAlchemy, tearDown=tearDownWithCrateLayer, optionflags=flags) s.layer = crate_layer suite.addTest(s) return suite
def test_suite(): suite = DocTestSuite(checker=RENormalizing([(re.compile(r'Revision="\d+"'), 'Revision="1999"')])) suite.layer = LaunchpadFunctionalLayer return suite
def test_suite(): suite = unittest.TestSuite() flags = (doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS) checker = RENormalizing([ # python 3 drops the u" prefix on unicode strings (re.compile(r"u('[^']*')"), r"\1"), # python 3 includes module name in exceptions (re.compile(r"crate.client.exceptions.ProgrammingError:"), "ProgrammingError:"), (re.compile(r"crate.client.exceptions.ConnectionError:"), "ConnectionError:"), (re.compile(r"crate.client.exceptions.DigestNotFoundException:"), "DigestNotFoundException:"), (re.compile(r"crate.client.exceptions.BlobLocationNotFoundException:"), "BlobLocationNotFoundException:"), (re.compile(r"<type "), "<class "), ]) s = doctest.DocFileSuite( 'doctests/cursor.txt', 'doctests/connection.txt', checker=checker, setUp=setUpMocked, optionflags=flags, encoding='utf-8' ) suite.addTest(s) suite.addTest(unittest.makeSuite(CursorTest)) suite.addTest(unittest.makeSuite(HttpClientTest)) suite.addTest(unittest.makeSuite(KeepAliveClientTest)) suite.addTest(unittest.makeSuite(ThreadSafeHttpClientTest)) suite.addTest(unittest.makeSuite(ParamsTest)) suite.addTest(unittest.makeSuite(ConnectionTest)) suite.addTest(unittest.makeSuite(RetryOnTimeoutServerTest)) suite.addTest(unittest.makeSuite(RequestsCaBundleTest)) suite.addTest(unittest.makeSuite(TestUsernameSentAsHeader)) suite.addTest(unittest.makeSuite(TestDefaultSchemaHeader)) suite.addTest(sqlalchemy_test_suite()) suite.addTest(doctest.DocTestSuite('crate.client.connection')) suite.addTest(doctest.DocTestSuite('crate.client.http')) s = doctest.DocFileSuite( 'doctests/https.txt', checker=checker, setUp=setUpWithHttps, optionflags=flags, encoding='utf-8' ) s.layer = HttpsTestServerLayer() suite.addTest(s) s = doctest.DocFileSuite( 'sqlalchemy/doctests/itests.txt', 'sqlalchemy/doctests/dialect.txt', 'sqlalchemy/doctests/reflection.txt', checker=checker, setUp=setUpCrateLayerAndSqlAlchemy, tearDown=tearDownWithCrateLayer, optionflags=flags, encoding='utf-8' ) s.layer = crate_layer suite.addTest(s) s = doctest.DocFileSuite( 'doctests/http.txt', 'doctests/blob.txt', 'doctests/client.txt', 'doctests/mocking.txt', 'doctests/blob.txt', checker=checker, setUp=setUpWithCrateLayer, tearDown=tearDownWithCrateLayer, optionflags=flags, encoding='utf-8' ) s.layer = crate_layer suite.addTest(s) s = doctest.DocFileSuite( 'doctests/sqlalchemy.txt', checker=checker, setUp=setUpCrateLayerAndSqlAlchemy, tearDown=tearDownWithCrateLayer, optionflags=flags, encoding='utf-8' ) s.layer = crate_layer suite.addTest(s) return suite
from unittest import TestSuite from zc.buildout.testing import buildoutSetUp, buildoutTearDown from zc.buildout.testing import install, install_develop from zc.buildout.testing import normalize_endings from zc.buildout.testing import normalize_path from zc.buildout.testing import normalize_script from zope.testing.renormalizing import RENormalizing checker = RENormalizing([ normalize_endings, normalize_script, normalize_path, # a new one with buildout 2.0 (re.compile("Not found: .+\n"), ''), # only appear on Python 2.6?! (re.compile("Installing checker.\n"), ''), # the usual one that needs ignoring (re.compile("Couldn't find index page for '[a-zA-Z0-9.]+' " "\(maybe misspelled\?\)" "\n"), ''), ]) def setUp(test): buildoutSetUp(test) install('zc.recipe.egg', test) install('argparse', test) install('execute', test) install('mailinglogger', test)