if PY3: py3_checker = renormalizing.RENormalizing([ (re.compile(r"u'([^']*)'"), r"'\1'"), (re.compile(r"^b'([^']*)'"), r"'\1'"), (re.compile(r"([^'])b'([^']*)'"), r"\1'\2'"), (re.compile(r"<class 'bytes'>"), r"<type 'str'>"), (re.compile(r"<class 'str'>"), r"<type 'unicode'>"), (re.compile(r"zope.schema._bootstrapinterfaces.InvalidValue"), r"InvalidValue"), (re.compile(r"zope.schema.interfaces.InvalidId: '([^']*)'"), r"InvalidId: \1"), (re.compile(r"zope.schema.interfaces.InvalidId:"), r"InvalidId:"), (re.compile(r"zope.schema.interfaces.InvalidURI: '([^']*)'"), r"InvalidURI: \1"), (re.compile(r"zope.schema.interfaces.InvalidURI:"), r"InvalidURI:"), (re.compile(r"zope.schema.interfaces.InvalidDottedName: '([^']*)'"), r"InvalidDottedName: \1"), (re.compile(r"zope.schema.interfaces.InvalidDottedName:"), r"InvalidDottedName:"), (re.compile( r"zope.schema._bootstrapinterfaces.ConstraintNotSatisfied: '([^']*)'" ), r"ConstraintNotSatisfied: \1"), (re.compile( r"zope.schema._bootstrapinterfaces.ConstraintNotSatisfied:"), r"ConstraintNotSatisfied:"), (re.compile(r"zope.schema._bootstrapinterfaces.WrongType:"), r"WrongType:"), ]) else: py3_checker = renormalizing.RENormalizing([
from zope.testing import renormalizing import doctest import re checker = renormalizing.RENormalizing([ (re.compile(r'<Event [0-9a-f]*::'), '<Event 12341234::'), (re.compile(r'<SQSEvent [0-9a-f]*::'), '<SQSEvent 12341234::'), (re.compile(r'datetime.datetime(.*)'), 'datetime.datetime(2011, 10, 1, 9, 45)'), (re.compile(r"ObjectId\('[0-9a-f]*'\)"), "ObjectId('4e7ddf12e138237403000000')"), (re.compile(r"object at 0x[0-9a-f]*>"), "object at 0x001122>"), (re.compile('at 0x[0-9a-f]+'), 'at <SOME ADDRESS>'), #flexible isoformat T or space (re.compile(r"20\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])(T| )"\ "\d\d:\d\d\:\d\d.[0-9]*Z*"), "2011-12-13 07:47:51.921000"), #email header (re.compile(r"X-Peer: .*"), "127.0.0.1:54321"), ]) OPTIONFLAGS = ( doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | doctest.REPORT_ONLY_FIRST_FAILURE
import os.path import unittest import doctest import manuel.capture import manuel.codeblock import manuel.doctest import manuel.ignore import manuel.testing from zope.testing import renormalizing checker = renormalizing.RENormalizing([ # Python 3 unicode removed the "u". (re.compile("u('.*?')"), r"\1"), (re.compile('u(".*?")'), r"\1"), # Python 3 bytes added the "b". (re.compile("b('.*?')"), r"\1"), (re.compile('b(".*?")'), r"\1"), ]) optionflags = ( doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL ) def test_suite(): here = os.path.dirname(os.path.abspath(__file__)) while not os.path.exists(os.path.join(here, 'setup.py')): prev, here = here, os.path.dirname(here) if here == prev:
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## import doctest import persistent.mapping import re import transaction import unittest import ZODB.tests.util from zope.testing import renormalizing checker = renormalizing.RENormalizing([ # Python 3 bytes add a "b". (re.compile("b('.*?')"), r"\1"), # Python 3 adds module name to exceptions. (re.compile("ZODB.POSException.ConnectionStateError"), r"ConnectionStateError"), ]) def testAddingThenModifyThenAbort(): """\ We ran into a problem in which abort failed after adding an object in a savepoint and then modifying the object. The problem was that, on commit, the savepoint was aborted before the modifications were aborted. Because the object was added in the savepoint, its _p_oid and _p_jar were cleared when the savepoint was aborted. The object was in the registered-object list. There's an invariant for this list that states that all objects in the list should have an oid and (correct) jar.
import os import re import unittest import doctest from zope.testing import renormalizing checker = renormalizing.RENormalizing([ # str(Exception) has changed from Python 2.4 to 2.5 (due to # Exception now being a new-style class). This changes the way # exceptions appear in traceback printouts. (re.compile(r"ConfigurationExecutionError: <class '([\w.]+)'>:"), r'ConfigurationExecutionError: \1:'), ]) optionflags=(doctest.ELLIPSIS+ doctest.NORMALIZE_WHITESPACE) main_doctests = ['README.txt'] def test_suite(): suite = unittest.TestSuite() for testfile in main_doctests: suite.addTest( doctest.DocFileSuite( os.path.join('..', testfile), optionflags=optionflags, globs=globals(), checker=checker)) return suite
def test_suite(): suite = unittest.TestSuite(( doctest.DocFileSuite( 'README.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, zc.buildout.testing.normalize_endings, zc.buildout.testing.normalize_script, zc.buildout.testing.normalize_egg_py, zc.buildout.tests.normalize_bang, zc.buildout.tests.normalize_S, zc.buildout.testing.not_found, (re.compile('[d-] zc.buildout(-\S+)?[.]egg(-link)?'), 'zc.buildout.egg'), (re.compile('[d-] setuptools-[^-]+-'), 'setuptools-X-'), (re.compile(r'eggs\\\\demo'), 'eggs/demo'), (re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'), ])), doctest.DocFileSuite( 'api.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, zc.buildout.testing.normalize_endings, zc.buildout.testing.not_found, (re.compile('__buildout_signature__ = ' 'sample-\S+\s+' 'zc.recipe.egg-\S+\s+' 'setuptools-\S+\s+' 'zc.buildout-\S+\s*'), '__buildout_signature__ = sample- zc.recipe.egg-'), (re.compile('find-links = http://localhost:\d+/'), 'find-links = http://localhost:8080/'), (re.compile('index = http://localhost:\d+/index'), 'index = http://localhost:8080/index'), ])), doctest.DocFileSuite( 'custom.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, zc.buildout.testing.normalize_endings, zc.buildout.testing.not_found, (re.compile("(d ((ext)?demo(needed)?|other)" "-\d[.]\d-py)\d[.]\d(-\S+)?[.]egg"), '\\1V.V.egg'), (re.compile('extdemo.c\n.+\\\\extdemo.exp\n'), ''), (re.compile( r'zip_safe flag not set; analyzing archive contents.*\n'), ''), (re.compile(r'\n.*module references __file__'), ''), (re.compile(''), ''), (re.compile( "extdemo[.]c\n" "extdemo[.]obj : warning LNK4197: " "export 'initextdemo' specified multiple times; " "using first specification\n" " Creating library build\\\\temp[.]win-amd64-2[.]" "[4567]\\\\Release\\\\extdemo[.]lib and object " "build\\\\temp[.]win-amd64-2[.][4567]\\\\Re" "lease\\\\extdemo[.]exp\n"), ''), ]), ), doctest.DocFileSuite('working_set_caching.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, zc.buildout.testing.normalize_endings, zc.buildout.testing.not_found, ])), )) return suite
except pkg_resources.DistributionNotFound: HAS_PA_CONTENTTYPES = False else: HAS_PA_CONTENTTYPES = True FLAGS = ( doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | doctest.REPORT_NDIFF | doctest.REPORT_ONLY_FIRST_FAILURE ) CHECKER = renormalizing.RENormalizing([ # Normalize the generated UUID values to always compare equal. (re.compile( r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'), '<UUID>', ), ]) def setUp(self): # pragma: no cover """Shared test environment set-up, ran before every test.""" layer = self.globs['layer'] # Update global variables within the tests. self.globs.update({ 'portal': layer['portal'], 'request': layer['request'], 'browser': Browser(layer['app']), 'TEST_USER_NAME': TEST_USER_NAME, 'TEST_USER_PASSWORD': TEST_USER_PASSWORD,
] zope.testbrowser.wsgi.TestBrowserLayer.__init__(self) zope.app.wsgi.testlayer.BrowserLayer.__init__(self, *args, **kw) def setUp(self): zope.app.appsetup.product.setProductConfigurations(self.conf) zope.app.wsgi.testlayer.BrowserLayer.setUp(self) old_1, old_2 = zope.i18n.negotiate, zope.i18n.config.ALLOWED_LANGUAGES zope.i18n.negotiate = lambda context: 'de' zope.i18n.config.ALLOWED_LANGUAGES = ['de'] layer = Layer(uvcsite, allowTearDown=True) checker = renormalizing.RENormalizing([ # Accommodate to exception wrapping in newer versions of mechanize (re.compile(r'httperror_seek_wrapper:', re.M), 'HTTPError:'), ]) def http_call(app, method, path, data=None, **kw): """Function to help make RESTful calls. method - HTTP method to use path - testbrowser style path data - (body) data to submit kw - any request parameters """ if path.startswith('http://localhost'): path = path[len('http://localhost'):] request_string = '%s %s HTTP/1.1\n' % (method, path)
"""Browser Menu Item Tests """ import doctest import pprint import re import unittest from zope.testing import cleanup, renormalizing checker = renormalizing.RENormalizing([ # Python 3 unicode removed the "u". (re.compile("u('.*?')"), r"\1"), (re.compile('u(".*?")'), r"\1"), # Python 3 changed builtins name. (re.compile('__builtin__'), r"builtins"), # Python 3 renamed type to class. (re.compile('<type'), r"<class"), # Python 3 adds module name to exceptions. (re.compile("zope.configuration.exceptions.ConfigurationError"), r"ConfigurationError"), ]) def test_suite(): return unittest.TestSuite(( doctest.DocFileSuite('../README.txt', setUp=lambda test:cleanup.setUp(), tearDown=lambda test:cleanup.tearDown(), globs={'pprint': pprint.pprint}, checker=checker,
zc.buildout.testing.install("zope.schema", test) zc.buildout.testing.install("zope.security", test) zc.buildout.testing.install("zope.tal", test) zc.buildout.testing.install_develop("z3c.recipe.i18n", test) checker = renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, ( re.compile(r"Couldn't find index page for '[a-zA-Z0-9.]+' " r"\(maybe misspelled\?\)" r"\n"), "", ), ( re.compile("""['"][^\n"']+z3c.recipe.i18n[^\n"']*['"],"""), "'/z3c.recipe.i18n',", ), (re.compile("#![^\n]+\n"), ""), (re.compile(r"-\S+-py\d[.]\d(-\S+)?.egg"), "-pyN.N.egg"), # the following are for compatibility with Windows (re.compile(r"- .*\.exe\n"), ""), (re.compile("-script.py"), ""), (re.compile(r"\\[\\]?"), "/"), (re.compile("outputDir"), "outputdir"), ]) def test_suite(): return unittest.TestSuite( doctest.DocFileSuite( "README.rst",
# FOR A PARTICULAR PURPOSE. # ############################################################################## """General test support. """ import re from zope.testing import renormalizing checker = renormalizing.RENormalizing([ # Python 3 unicode removed the "u". (re.compile("u('.*?')"), r"\1"), (re.compile('u(".*?")'), r"\1"), # Python 3 bytes adds the "b". (re.compile("b('.*?')"), r"\1"), (re.compile('b(".*?")'), r"\1"), # Python 3 changed the set representation. (re.compile("set\(\[(.*)\]\)"), r"{\1}"), # Python 3 renames builtins. (re.compile("__builtin__"), r"builtins"), # Python 3 adds module name to exceptions. (re.compile("zope.schema.interfaces.SchemaNotProvided"), r"SchemaNotProvided"), ]) class VerifyResults(object): """Mix-in for test classes with helpers for checking string data.""" def verifyResult(self, result, check_list, inorder=False): start = 0 for check in check_list: pos = result.find(check, start)
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Test not found errors """ import doctest import re import unittest from zope.testing import renormalizing from zope.app.publication.testing import PublicationLayer checker = renormalizing.RENormalizing([ (re.compile(r"HTTP/1\.([01]) (\d\d\d) .*"), r"HTTP/1.\1 \2 <MESSAGE>"), ]) optionflags = doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE def test_suite(): methodnotallowed = doctest.DocFileSuite('../methodnotallowed.txt', optionflags=optionflags) methodnotallowed.layer = PublicationLayer notfound = doctest.DocFileSuite('../notfound.txt', optionflags=optionflags) notfound.layer = PublicationLayer httpfactory = doctest.DocFileSuite('../httpfactory.txt', checker=checker, optionflags=optionflags) httpfactory.layer = PublicationLayer
os.chmod(fname, stat.S_IWUSR) os.remove(fname) for dname in dirs: dname = os.path.join(cpath, dname) os.rmdir(dname) os.rmdir(path) checker = renormalizing.RENormalizing([ # Python 3 bytes add a "b". (re.compile(r'b(".*?")'), r"\1"), (re.compile(r"b('.*?')"), r"\1"), # Windows shows result from 'u64' as long? (re.compile(r"(\d+)L"), r"\1"), # Python 3 adds module name to exceptions. (re.compile("ZODB.POSException.ConflictError"), r"ConflictError"), (re.compile("ZODB.POSException.POSKeyError"), r"POSKeyError"), (re.compile("ZODB.POSException.ReadConflictError"), r"ReadConflictError"), (re.compile("ZODB.POSException.Unsupported"), r"Unsupported"), (re.compile("ZODB.interfaces.BlobError"), r"BlobError"), # XXX document me (re.compile(r'\%(sep)s\%(sep)s' % dict(sep=os.path.sep)), '/'), (re.compile(r'\%(sep)s' % dict(sep=os.path.sep)), '/'), ]) try: file_type = file PY3 = False except NameError: # Py3: Python 3 does not have a file type. import io file_type = io.BufferedReader
import re import unittest from zope.testing import renormalizing from martian.testing import FakeModule from martian.testing import FakeModuleObject optionflags = (doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS | doctest.IGNORE_EXCEPTION_DETAIL) globs = dict(FakeModule=FakeModule, object=FakeModuleObject) checker = renormalizing.RENormalizing([ (re.compile(r'<builtins\.'), r'<'), (re.compile(r'<__builtin__\.'), r'<'), ]) def test_suite(): suite = unittest.TestSuite() suite.addTests([ doctest.DocFileSuite('README.rst', package='martian', globs=globs, checker=checker, optionflags=optionflags), doctest.DocFileSuite('scan.rst', package='martian', optionflags=optionflags), doctest.DocFileSuite('directive.rst',
import os.path import re import unittest from zope.testing import renormalizing from zope.testing import cleanup import manuel.capture import manuel.codeblock import manuel.doctest import manuel.ignore import manuel.testing checker = renormalizing.RENormalizing([ # Python 3 bytes add a "b". (re.compile("b('.*?')"), r"\1"), # and remove the 'u' (re.compile("u('.*?')"), r"\1"), ]) # Sphinx-ext-doctest dosen't run ..code-block:: expressions, # it needs ..testcode. Make manuel recognize that too # Obviously the better way to do this would be to write # our own; it's a pretty simple module.. But this is faster. CODEBLOCK_START = re.compile( r'(^\.\.\s*(invisible-)?code(-block)?::?\s*python\b(?:\s*\:[\w-]+\:.*\n)*)' r'|(^\.\.\s*testcode::)', re.MULTILINE) manuel.codeblock.CODEBLOCK_START = CODEBLOCK_START def test_suite():
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## import doctest import megrok.strictrequire.tests import unittest import zope.component.testlayer from zope.testing import renormalizing layer = zope.component.testlayer.ZCMLFileLayer(megrok.strictrequire.tests) checker = renormalizing.RENormalizing() def test_suite(): suite = unittest.TestSuite() suite.addTest( doctest.DocFileSuite( 'checkrequire.rst', checker=checker, optionflags=(doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS + renormalizing.IGNORE_EXCEPTION_MODULE_IN_PYTHON2))) suite.layer = layer return suite
'SUBMIT_ROLE': 'Save Changes'}, basic='mgr:mgrpw', handle_errors=True) body = response.getBody() self.assert_('You choose both allow and deny for permission' ' "Local Permission". This is not allowed.' in body) _result = '''\ <option value="Unset"> </option> <option value="Allow" selected="selected">+</option> <option value="Deny">-</option> ''' checker = renormalizing.RENormalizing([ (re.compile(r"HTTP/1\.1 (\d\d\d) .*"), r"HTTP/1.1 \1 <MESSAGE>"), ]) def test_suite(): RolePermissionsTest.layer = SecurityPolicyLayer granting = functional.FunctionalDocFileSuite( '../granting_ftest.txt', checker=checker) granting.layer = SecurityPolicyLayer return unittest.TestSuite(( unittest.makeSuite(RolePermissionsTest), granting, )) if __name__ == '__main__':
from zope.schema.interfaces import ITextLine from zope.component import testing import zope.app.form.testing as ztapi from zope.app.form.browser import TextWidget from zope.formlib.interfaces import IInputWidget from zope.testing import renormalizing import re checker = renormalizing.RENormalizing([ (re.compile("u('.*?')"), r"\1"), (re.compile('u(".*?")'), r"\1"), # Python 3 adds module name to exceptions. (re.compile('zope.configuration.xmlconfig.ZopeXMLConfigurationError'), 'ZopeXMLConfigurationError'), ]) def setUp(test): testing.setUp() ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget) def test_suite(): return unittest.TestSuite( (doctest.DocFileSuite('../form.rst', setUp=setUp, tearDown=testing.tearDown,
import ZODB.tests.util from ZODB.config import databaseFromString from ZODB.utils import p64, u64, z64 from persistent import Persistent from zope.interface.verify import verifyObject from zope.testing import loggingsupport, renormalizing from .. import mvccadapter checker = renormalizing.RENormalizing([ # Python 3 bytes add a "b". (re.compile("b('.*?')"), r"\1"), # Python 3 removes empty list representation. (re.compile(r"set\(\[\]\)"), r"set()"), # Python 3 adds module name to exceptions. (re.compile("ZODB.POSException.POSKeyError"), r"POSKeyError"), (re.compile("ZODB.POSException.ReadConflictError"), r"ReadConflictError"), (re.compile("ZODB.POSException.ConflictError"), r"ConflictError"), (re.compile("ZODB.POSException.ConnectionStateError"), r"ConnectionStateError"), ]) class ConnectionDotAdd(ZODB.tests.util.TestCase): def setUp(self): ZODB.tests.util.TestCase.setUp(self) from ZODB.Connection import Connection self.db = StubDatabase() self.datamgr = Connection(self.db) self.datamgr.open() self.transaction = Transaction()
<BLANKLINE> <div class="generatedby"> <p>Generated by irclogsearch.py ... by <a href="mailto:[email protected]">Marius Gedminas</a> - find it at <a href="http://mg.pov.lt/irclog2html/">mg.pov.lt</a>!</p> </div> </body> </html> >>> clean_up_sample(tmpdir) """ checker = None if sys.version_info[0] == 2: checker = renormalizing.RENormalizing([ (re.compile(r"^\['"), r"[b'"), (re.compile(r"u('.*?')"), r"\1"), ]) def test_suite(): optionflags = (doctest.ELLIPSIS | doctest.REPORT_NDIFF | doctest.NORMALIZE_WHITESPACE) return unittest.TestSuite([ doctest.DocTestSuite(optionflags=optionflags, checker=checker), ]) if __name__ == '__main__': unittest.main(defaultTest='test_suite')
WidgetsError: KeyError: 'bar' The handler of error can access all of the widget error as well as the widget values read: >>> for error in widgetsError: ... error.__class__.__name__ 'KeyError' >>> widgetsError.widgetsData {'foo': 'Foo'} """ from zope.testing import renormalizing import re checker = renormalizing.RENormalizing([ (re.compile("u('.*?')"), r"\1"), (re.compile('u(".*?")'), r"\1"), # Python 3 adds module name to exceptions. (re.compile('zope.interface.exceptions.Invalid'), 'Invalid'), (re.compile('zope.security.interfaces.Unauthorized'), 'Unauthorized'), (re.compile('zope.security.interfaces.ForbiddenAttribute'), 'ForbiddenAttribute'), (re.compile('zope.formlib.interfaces.WidgetsError'), 'WidgetsError'), ]) def test_suite(): return doctest.DocTestSuite(checker=checker)
try: response = self.publish('/pf/@@contents.html', basic='mgr:mgrpw', form={'container_paste_button': ''}) except UserError, e: self.assertEqual( str(e), "The given name(s) [u'p1'] is / are already being used") else: # test failed ! self.asserEqual(1, 0) checker = renormalizing.RENormalizing([ (re.compile(r"HTTP/1\.1 200 .*"), "HTTP/1.1 200 OK"), (re.compile(r"HTTP/1\.1 303 .*"), "HTTP/1.1 303 See Other"), (re.compile(r"HTTP/1\.1 401 .*"), "HTTP/1.1 401 Unauthorized"), ]) def test_suite(): FunkTest.layer = AppAuthenticationLayer principalfolder = functional.FunctionalDocFileSuite('principalfolder.txt', checker=checker) principalfolder.layer = AppAuthenticationLayer groupfolder = functional.FunctionalDocFileSuite('groupfolder.txt', checker=checker) groupfolder.layer = AppAuthenticationLayer pau_prefix_and_searching = functional.FunctionalDocFileSuite( 'pau_prefix_and_searching.txt', checker=checker) pau_prefix_and_searching.layer = AppAuthenticationLayer
import os import re import time import transaction import unittest import ZODB.blob import ZODB.FileStorage import ZODB.tests.util from ZODB.Connection import TransactionMetaData from zope.testing import renormalizing checker = renormalizing.RENormalizing([ # Python 3 bytes add a "b". (re.compile("b('.*?')"), r"\1"), # Python 3 adds module name to exceptions. (re.compile("ZODB.POSException.POSKeyError"), r"POSKeyError"), (re.compile("ZODB.FileStorage.FileStorage.FileStorageQuotaError"), "FileStorageQuotaError"), (re.compile('data.fs:[0-9]+'), 'data.fs:<OFFSET>'), ]) def pack_keep_old(): """Should a copy of the database be kept? The pack_keep_old constructor argument controls whether a .old file (and .old directory for blobs is kept.) >>> fs = ZODB.FileStorage.FileStorage('data.fs', blob_dir='blobs') >>> db = ZODB.DB(fs) >>> conn = db.open()
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## import os, re, sys, unittest, doctest import zc.lockfile, time, threading from zope.testing import renormalizing, setupstack import tempfile try: from unittest.mock import Mock, patch except ImportError: from mock import Mock, patch checker = renormalizing.RENormalizing([ # Python 3 adds module path to error class name. (re.compile("zc\.lockfile\.LockError:"), r"LockError:"), ]) def inc(): while 1: try: lock = zc.lockfile.LockFile('f.lock') except zc.lockfile.LockError: continue else: break f = open('f', 'r+b') v = int(f.readline().strip()) time.sleep(0.01) v += 1
'zope.pagetemplate', 'zope.tales'): try: zc.buildout.testing.install(project, test) except AttributeError: pass checker = renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, (re.compile("Couldn't find index page for '[a-zA-Z0-9.]+' " "\(maybe misspelled\?\)" "\n"), ''), (re.compile("""['"][^\n"']+z3c.recipe.i18n[^\n"']*['"],"""), "'/z3c.recipe.i18n',"), (re.compile('#![^\n]+\n'), ''), ( re.compile('-\S+-py\d[.]\d(-\S+)?.egg'), '-pyN.N.egg', ), # the following are for compatibility with Windows (re.compile('- .*\.exe\n'), ''), (re.compile('-script.py'), ''), (re.compile(r'\\[\\]?'), '/'), (re.compile('outputDir'), 'outputdir'), ]) def test_suite(): return unittest.TestSuite( doctest.DocFileSuite('README.txt', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
Clean up. >>> st.close() >>> st.cleanup() # remove .fs, .index, etc """ import doctest import re from zope.testing import renormalizing from .util import checker as util_checker from .util import setUp from .util import tearDown checker = renormalizing.RENormalizing([ # Normalizing this makes diffs easier to read (re.compile(r'\btid 0x[0-9a-f]+\b'), 'tid 0x...'), (re.compile(r'\b\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\.\d+\b'), '...'), # Python 3 produces larger pickles, even when we use zodbpickle :( # this changes all the offsets and sizes (re.compile(r'\boffset=[0-9]+\b'), 'offset=<OFFSET>'), (re.compile(r'\bat [0-9]+'), 'at <OFFSET>'), ]) def test_suite(): return doctest.DocTestSuite(setUp=setUp, tearDown=tearDown, checker=util_checker + checker, optionflags=doctest.REPORT_NDIFF)
checker = renormalizing.RENormalizing([ # Date formatting (re.compile(r'\d{4}-\d{2}-\d{2}'), '1972-12-25'), # Hg tag list hash formatting (re.compile(r'\d:[0-9a-f]{12}'), '1:234567890abc'), # Hg bare hash formatting (re.compile(r'[0-9a-f]{12}'), '234567890abc'), # Hg has an updated comment (re.compile('updating working directory'), 'updating to branch default'), # Newer Hg no longer prints 'requesting all changes' (re.compile('requesting all changes'), ''), # Git diff hash formatting (re.compile(r'[0-9a-f]{7}\.\.[0-9a-f]{7} [0-9a-f]{6}'), '1234567..890abcd ef0123'), # .pypirc seems to be case insensitive (re.compile('[Pp][Yy][Pp][Ii]'), 'pypi'), # Normalize tempdirs. For this to work reliably, we need to use a prefix # in all tempfile.mkdtemp() calls. (re.compile('%s/testtemp[^/]+/svnrepo' % re.escape(tempfile.gettempdir())), 'TESTREPO'), (re.compile('/private%s/testtemp[^/]+' % re.escape(tempfile.gettempdir())), 'TESTTEMP'), # OSX madness (re.compile('%s/testtemp[^/]+' % re.escape(tempfile.gettempdir())), 'TESTTEMP'), (re.compile(re.escape(tempfile.gettempdir())), 'TMPDIR'), # Python 2.7 prints 'Creating tar archive' instead of # 'tar -cf dist/tha.example-0.1.tar tha.example-0.1 # ...': (re.compile('tar -cf dist/tha.example-0.1.tar tha.example-0.1'), 'Creating tar archive'), # Harmless line when using subversion 1.7: (re.compile('unrecognized .svn/entries format in'), ''), # git before 1.7.9.2 reported 0 deletions when committing: (re.compile(', 0 deletions\(-\)'), ''), # Change in git 1.7.9.2: '1 files changed': (re.compile(' 1 files changed'), ' 1 file changed'), # Change in git 1.8.0: (re.compile('nothing to commit \(working directory clean\)'), 'nothing to commit, working directory clean'), # Change in git 2.9.1: (re.compile('nothing to commit, working directory clean'), 'nothing to commit, working tree clean'), # Change in git 1.8.5, the hash is removed: (re.compile('# On branch'), 'On branch'), # Hg 3.3 prints 'committing files' or 'committing <filename>' (re.compile(r'^committing.*'), ''), # We should ignore coloring by colorama. Or actually print it # clearly. This catches Fore.RED and Fore.MAGENTA. # Note the extra backslash in front of the left bracket, otherwise # you get: "error: unexpected end of regular expression" (re.compile(re.escape(Fore.RED)), 'RED '), (re.compile(re.escape(Fore.MAGENTA)), 'MAGENTA '), # svn 1.9 prints 'Committing transaction...' (re.compile('Committing transaction...'), ''), (re.compile('FileNotFoundError'), 'IOError'), # mercurial 4.4.1 includes an extra line in checkout_from_tag, e.g.: # new changesets 234567890abc:234567890abc (re.compile('new changesets [0-9a-f]{12}:[0-9a-f]{12}'), ''), ] + ([] if six.PY3 else [ (re.compile('u\''), '\''), (re.compile('u"'), '"'), (re.compile('zest.releaser.utils.CommandException'), 'CommandException'), ]))
required=False) somenumber = Int(title=_(u"Some number"), default=0, required=False) somelist = List(title=_(u"Some List"), value_type=TextLine(title=_(u"Some item")), default=[], required=False) class FieldContent(Persistent): implements(IFieldContent) checker = renormalizing.RENormalizing([ (re.compile(r"HTTP/1\.1 200 .*"), "HTTP/1.1 200 OK"), ]) def test_suite(): i18n = FunctionalDocFileSuite('i18n.txt', package='zope.app.form.browser', checker=checker) i18n.layer = AppFormLayer return unittest.TestSuite([ i18n, ]) if __name__ == '__main__': unittest.main(defaultTest='test_suite')
import doctest import unittest from zope.testing import renormalizing def setUp(test): zc.buildout.testing.buildoutSetUp(test) zc.buildout.testing.install_develop('collective.recipe.template', test) zc.buildout.testing.install('zope.testing', test) zc.buildout.testing.install('Genshi', test) checker = renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, (re.compile('#![^\n]+\n'), ''), (re.compile('-\S+-py\d[.]\d(-\S+)?.egg'), '-pyN.N.egg'), ]) def test_suite(): return unittest.TestSuite([ doctest.DocFileSuite('README.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE, checker=checker), doctest.DocFileSuite('genshitemplate.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
def test_suite(): suites = [ doctest.DocFileSuite( 'README.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, zc.buildout.testing.normalize_endings, zc.buildout.testing.normalize_script, zc.buildout.testing.normalize_egg_py, zc.buildout.tests.normalize_bang, zc.buildout.tests.normalize_S, zc.buildout.testing.not_found, zc.buildout.testing.python27_warning, zc.buildout.testing.python27_warning_2, (re.compile(r'[d-] zc.buildout(-\S+)?[.]egg(-link)?'), 'zc.buildout.egg'), (re.compile(r'[d-] setuptools-[^-]+-'), 'setuptools-X-'), (re.compile(r'[d-] pip-[^-]+-'), 'pip-X-'), (re.compile(r'eggs\\\\demo'), 'eggs/demo'), (re.compile(r'[a-zA-Z]:\\\\foo\\\\bar'), '/foo/bar'), ]) ), doctest.DocFileSuite( 'api.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, zc.buildout.testing.normalize_endings, zc.buildout.testing.not_found, zc.buildout.testing.python27_warning, zc.buildout.testing.python27_warning_2, (re.compile('__buildout_signature__ = ' r'sample-\S+\s+' r'zc.recipe.egg-\S+\s+' r'setuptools-\S+\s+' r'zc.buildout-\S+\s*' ), '__buildout_signature__ = sample- zc.recipe.egg-'), (re.compile(r'find-links = http://localhost:\d+/'), 'find-links = http://localhost:8080/'), (re.compile(r'index = http://localhost:\d+/index'), 'index = http://localhost:8080/index'), ]) ), doctest.DocFileSuite( 'working_set_caching.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, zc.buildout.testing.normalize_endings, zc.buildout.testing.not_found, ]) ), ] if not WINDOWS: suites.append( doctest.DocFileSuite( 'custom.rst', setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS, checker=renormalizing.RENormalizing([ zc.buildout.testing.normalize_path, zc.buildout.testing.normalize_endings, zc.buildout.testing.not_found, zc.buildout.testing.python27_warning, zc.buildout.testing.python27_warning_2, (re.compile("(d ((ext)?demo(needed)?|other)" r"-\d[.]\d-py)\d[.]\d(-\S+)?[.]egg"), '\\1V.V.egg'), ]), ) ) suite = unittest.TestSuite(suites) return suite