[Twisted-Python] Re: [Twisted-commits] r22733 - Add clear() method to TestSuite, play with DocTestSuite (ahah some much fun).
![](https://secure.gravatar.com/avatar/1327ce755b24b956995d68accae3eab2.jpg?s=120&d=mm&r=g)
On Sat, Mar 1, 2008 at 9:02 AM, Thomas Herve <therve@wolfwood.twistedmatrix.com> wrote:
@@ -1241,6 +1242,13 @@ return result
+ def clear(self): + """ + Remove all previously added tests. + """ + self._tests = [] + +
class TestDecorator(components.proxyForInterface(itrial.ITestCase, "_originalTest")): @@ -1293,8 +1301,8 @@ # Originally, we recreated the suite by calling test.__class__. The problem # was that the old suite kept references to test instances, which turns out # to never be free. Now we remove the original references by emptying the - # _tests list. - test._tests = [] + # list of tests. + test.clear()
What's your plan for making sure this works with stdlib TestSuite? jml
![](https://secure.gravatar.com/avatar/79b398e90ee81bd64ec95da03c16f36c.jpg?s=120&d=mm&r=g)
Jonathan Lange a écrit :
On Sat, Mar 1, 2008 at 9:02 AM, Thomas Herve <therve@wolfwood.twistedmatrix.com> wrote:
@@ -1241,6 +1242,13 @@ return result
+ def clear(self): + """ + Remove all previously added tests. + """ + self._tests = [] + What's your plan for making sure this works with stdlib TestSuite?
jml
I haven't think about it much. The tests aren't broken, so the behavior is not really defined. I could just check if the method exists, but that doesn't seem very nice. Maybe we could have a ITestSuite interface to add specific behavior to the twisted TestSuite object (and then check the interface). Or maybe I could just let the old self._tests = [], but exarkun wasn't very happy about that. What do you think? -- Thomas
![](https://secure.gravatar.com/avatar/7ed9784cbb1ba1ef75454034b3a8e6a1.jpg?s=120&d=mm&r=g)
On Sat, 01 Mar 2008 10:39:49 +0100, Thomas Hervé <therve@free.fr> wrote:
Jonathan Lange a écrit :
On Sat, Mar 1, 2008 at 9:02 AM, Thomas Herve <therve@wolfwood.twistedmatrix.com> wrote:
@@ -1241,6 +1242,13 @@ return result
+ def clear(self): + """ + Remove all previously added tests. + """ + self._tests = [] + What's your plan for making sure this works with stdlib TestSuite?
jml
I haven't think about it much. The tests aren't broken, so the behavior is not really defined. I could just check if the method exists, but that doesn't seem very nice. Maybe we could have a ITestSuite interface to add specific behavior to the twisted TestSuite object (and then check the interface). Or maybe I could just let the old self._tests = [], but exarkun wasn't very happy about that.
What do you think?
We're already adapting everything we come across to ITestCase. It seems that clear should be a method of that interface. If necessary, we can provide an adapter from the stdlib TestSuite which defines that method. Testing should be a simple matter then. Jean-Paul
participants (3)
-
Jean-Paul Calderone
-
Jonathan Lange
-
Thomas Hervé