summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-10-21 18:55:34 +0000
committerChris McDonough <chrism@agendaless.com>2009-10-21 18:55:34 +0000
commitb06b260b83bfc2f40105c6e730f5e7e8eccd61d9 (patch)
treeea0d681dbc83e0c88b76135561f41f0bfe90cf46 /repoze/bfg/tests
parent0ff9a894dbe1a1d6b71b74649a05bce2a91f5808 (diff)
downloadpyramid-b06b260b83bfc2f40105c6e730f5e7e8eccd61d9.tar.gz
pyramid-b06b260b83bfc2f40105c6e730f5e7e8eccd61d9.tar.bz2
pyramid-b06b260b83bfc2f40105c6e730f5e7e8eccd61d9.zip
- Fix bug encountered during "scan" (when ``<scan ..>`` directive is
used in ZCML) introduced in 1.1a7. Symptom: ``AttributeError: object has no attribute __provides__`` raised at startup time.
Diffstat (limited to 'repoze/bfg/tests')
-rw-r--r--repoze/bfg/tests/test_zcml.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/repoze/bfg/tests/test_zcml.py b/repoze/bfg/tests/test_zcml.py
index 282c27472..d6eb80c44 100644
--- a/repoze/bfg/tests/test_zcml.py
+++ b/repoze/bfg/tests/test_zcml.py
@@ -2544,6 +2544,48 @@ class TestExcludeFunction(unittest.TestCase):
self.assertEqual(self._callFUT('.foo'), True)
self.assertEqual(self._callFUT('foo'), False)
+class TestGetMembersFunction(unittest.TestCase):
+ def _callFUT(self, object, predicate=None):
+ from repoze.bfg.zcml import getmembers
+ return getmembers(object, predicate)
+
+ def test_with_attribute_error(self):
+ class Dummy:
+ @property
+ def raises(self):
+ raise AttributeError('raises')
+ ob = Dummy()
+ result = self._callFUT(ob, None)
+ result.sort()
+ self.assertEqual(result,
+ [('__doc__', None),
+ ('__module__', 'repoze.bfg.tests.test_zcml')]
+ )
+
+ def test_without_attribute_error(self):
+ class Dummy:
+ def doesntraise(self):
+ pass
+ ob = Dummy()
+ result = self._callFUT(ob, None)
+ result.sort()
+ self.assertEqual(result,
+ [('__doc__', None),
+ ('__module__', 'repoze.bfg.tests.test_zcml'),
+ ('doesntraise', ob.doesntraise)]
+ )
+
+ def test_predicate(self):
+ class Dummy:
+ def doesntraise(self):
+ pass
+ ob = Dummy()
+ def predicate(testing):
+ return getattr(testing, '__name__', None) == 'doesntraise'
+ result = self._callFUT(ob, predicate)
+ result.sort()
+ self.assertEqual(result,[('doesntraise', ob.doesntraise)])
+
class DummyModule:
__path__ = "foo"
__name__ = "dummy"