Commits

Olemis Lang committed 198817d

ThemeEngine #9580: Added test case detecting infinite recursion.

Comments (0)

Files changed (2)

+tho/themeengine/t-9580-tc-infinite-recursion.diff
 # Placed by Bitbucket

tho/themeengine/t-9580-tc-infinite-recursion.diff

+diff -r 1fac6fb904dc trac/tests/core.py
+--- a/trac/tests/core.py	Sat Jan 14 09:38:25 2012 +0000
++++ b/trac/tests/core.py	Thu Jan 19 14:14:39 2012 -0500
+@@ -249,6 +249,29 @@
+         self.assertEquals('x', tests.next().test())
+         self.assertRaises(StopIteration, tests.next)
+ 
++    def test_default_to_self_extension(self):
++        """
++        Verify there's no infinite recursion in __init__ if component provides 
++        default implementation for an interface for which it declared an 
++        extension point. Bug introduced by #9418 detected in th:ticket:9580 .
++        """
++        class ComponentA(Component):
++            implements(ITest)
++            tests = ExtensionPoint(ITest)
++            def __init__(self):
++                # Iterate over available extensions. This should trigger
++                # nested call to __init__ once again.
++                for c in self.tests:
++                    pass
++            def test(self):
++                return 'x'
++        MSG = 'maximum recursion depth exceeded while calling a Python object'
++        try:
++            c = ComponentA(self.compmgr)
++        except RuntimeError, exc:
++            self.assertEquals(MSG, str(exc), 'Infinite recursion. See #9418')
++            self.fail('Unknown runtime error')
++
+     def test_inherited_implements(self):
+         """
+         Verify that a component with a super-class implementing an extension