diff options
author | Jason Madden <jamadden@gmail.com> | 2017-06-29 12:44:25 -0500 |
---|---|---|
committer | Jason Madden <jamadden@gmail.com> | 2017-06-30 11:01:09 -0500 |
commit | 712bb8e078de20e01311cfe57d8dccfbbdcbe9b3 (patch) | |
tree | 4cb7d4e9cc901fe144d168b77eea235a08932787 /src/zope/component/tests/test__declaration.py | |
parent | 43d7351318eb373d1f4f500b70e4e461048c16f4 (diff) | |
download | zope-component-issue29.tar.gz |
100% coverageissue29
Add change note and badge to readme.
Remove unused class and function.
Omit standalonetests.py entirely from coverage.
Another unused class.
Incorporate feedback in test__api.py
* Bring back _callFUT and make the queryAdapterInContext tests call it
* Change raise NotImplentedError into specific fails_if_called() calls.
Remove redundant argument now that all test in Test_adapts pass under all versions.
Remove NotImplementedError from test_globalregistry.py
Remove NotImplementedError from test_hookable.py
Remove NotImplementedError from test_registry.py
Remove NotImplementedError from test_security.py
Remove NotImplementedError from test_zcml.py
Remove NotImplementedError from test_factory.py
Document ZCML feature and devmode.
Really accept all arguments unless opted out.
Diffstat (limited to 'src/zope/component/tests/test__declaration.py')
-rw-r--r-- | src/zope/component/tests/test__declaration.py | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/src/zope/component/tests/test__declaration.py b/src/zope/component/tests/test__declaration.py index b6c0767..470cab0 100644 --- a/src/zope/component/tests/test__declaration.py +++ b/src/zope/component/tests/test__declaration.py @@ -76,26 +76,13 @@ class Test_adapter(unittest.TestCase): class Test_adapts(unittest.TestCase): - def _run_generated_code(self, code, globs, locs, - fails_under_py3k=True, - ): + def _run_generated_code(self, code, globs, locs): import warnings - #from zope.component._compat import PYTHON3 - PYTHON3 = False with warnings.catch_warnings(record=True) as log: warnings.resetwarnings() - if not PYTHON3: - exec(code, globs, locs) - self.assertEqual(len(log), 0) # no longer warn - return True - else: - try: - exec(code, globs, locs) - except TypeError: - return False - else: - if fails_under_py3k: - self.fail("Didn't raise TypeError") + exec(code, globs, locs) + self.assertEqual(len(log), 0) # no longer warn + return True def test_instances_not_affected(self): from zope.component._declaration import adapts @@ -119,12 +106,12 @@ class Test_adapts(unittest.TestCase): 'def foo():', ' adapts(IFoo)' ]) - if self._run_generated_code(CODE, globs, locs, False): - foo = locs['foo'] - with warnings.catch_warnings(record=True) as log: - warnings.resetwarnings() - self.assertRaises(TypeError, foo) - self.assertEqual(len(log), 0) # no longer warn + self._run_generated_code(CODE, globs, locs) + foo = locs['foo'] + with warnings.catch_warnings(record=True) as log: + warnings.resetwarnings() + self.assertRaises(TypeError, foo) + self.assertEqual(len(log), 0) # no longer warn def test_called_twice_from_class(self): import warnings @@ -163,10 +150,10 @@ class Test_adapts(unittest.TestCase): 'class Foo(object):', ' adapts(IFoo)', ]) - if self._run_generated_code(CODE, globs, locs): - Foo = locs['Foo'] - spec = Foo.__component_adapts__ - self.assertEqual(list(spec), [IFoo]) + self._run_generated_code(CODE, globs, locs) + Foo = locs['Foo'] + spec = Foo.__component_adapts__ + self.assertEqual(list(spec), [IFoo]) class Test_adaptedBy(unittest.TestCase): @@ -211,11 +198,3 @@ class Test_adaptedBy(unittest.TestCase): baz = Baz() baz.__component_adapts__ = (IFoo, IBar) self.assertEqual(self._callFUT(baz), (IFoo, IBar)) - - -def test_suite(): - return unittest.TestSuite(( - unittest.makeSuite(Test_adapter), - unittest.makeSuite(Test_adapts), - unittest.makeSuite(Test_adaptedBy), - )) |