def test_w_testing_passed(self): import os from zope.configuration import xmlconfig from zope.configuration._compat import b from zope.configuration.tests import samplepackage from zope.configuration.tests.samplepackage import foo def _assertTestingTrue(func): def _wrapper(*args, **kw): assert (kw['testing']) return func(*args, **kw) return _wrapper fqn = _packageFile(samplepackage, 'configure.zcml') context = xmlconfig._getContext() context.execute_actions = _assertTestingTrue(context.execute_actions) with _Monkey(xmlconfig, processxmlfile=_assertTestingTrue( xmlconfig.processxmlfile)): self._callFUT(open(fqn), True) self.assertEqual(len(foo.data), 1) data = foo.data.pop(0) self.assertEqual(data.args, (('x', b('blah')), ('y', 0))) self.assertTrue( data.info.file.endswith( os.path.normpath('tests/samplepackage/configure.zcml'))) self.assertEqual(data.info.line, 12) self.assertEqual(data.info.column, 2) self.assertEqual(data.info.eline, 12) self.assertEqual(data.info.ecolumn, 29)
def test_w_testing_passed(self): import os from zope.configuration import xmlconfig from zope.configuration.tests import samplepackage from zope.configuration.tests.samplepackage import foo def _assertTestingTrue(func): def _wrapper(*args, **kw): assert kw['testing'] return func(*args, **kw) return _wrapper fqn = _packageFile(samplepackage, 'configure.zcml') context = xmlconfig._getContext() context.execute_actions = _assertTestingTrue(context.execute_actions) with _Monkey(xmlconfig, processxmlfile=_assertTestingTrue( xmlconfig.processxmlfile)): self._callFUT(open(fqn), True) self.assertEqual(len(foo.data), 1) data = foo.data.pop(0) self.assertEqual(data.args, (('x', (b'blah')), ('y', 0))) self.assertTrue( data.info.file.endswith( os.path.normpath('tests/samplepackage/configure.zcml'))) self.assertEqual(data.info.line, 12) self.assertEqual(data.info.column, 2) self.assertEqual(data.info.eline, 12) self.assertEqual(data.info.ecolumn, 29)
def test_it(self): import zope.component # no registrations made if not present ADAPTERS_REGISTERED = 4 from zope.configuration.xmlconfig import _clearContext from zope.configuration.xmlconfig import _getContext from zope.configuration.xmlconfig import XMLConfig import zope.location _clearContext() context = _getContext() XMLConfig('configure.zcml', zope.location) adapters = ([x for x in context.actions if x['discriminator'] is not None]) self.assertEqual(len(adapters), ADAPTERS_REGISTERED)
def test_it(self): import zope.component # no registrations made if not present ADAPTERS_REGISTERED = 4 from zope.configuration.xmlconfig import _clearContext from zope.configuration.xmlconfig import _getContext from zope.configuration.xmlconfig import XMLConfig import zope.location _clearContext() context = _getContext() XMLConfig('configure.zcml', zope.location) adapters = ([ x for x in context.actions if x['discriminator'] is not None ]) self.assertEqual(len(adapters), ADAPTERS_REGISTERED)
def parseZCML(package=package): context = xmlconfig._getContext() xmlconfig.include(context, 'configure.zcml', package) context.execute_actions()
def parseZCML(package, filename='configure.zcml'): context = xmlconfig._getContext() xmlconfig.include(context, filename, package) context.execute_actions()
def parseZCML(package, file='configure.zcml'): context = xmlconfig._getContext() xmlconfig.include(context, file, package) context.execute_actions()