[Twisted-Python] Refactoring of trial - call for feature requests and suggestions
Andrew Bennetts
andrew-twisted at puzzling.org
Thu Jun 17 05:52:14 MDT 2004
On Thu, Jun 17, 2004 at 07:26:30AM -0400, Jp Calderone wrote:
> Andrew Bennetts wrote:
> >On Thu, Jun 17, 2004 at 02:38:28AM -0400, Jp Calderone wrote:
> >
> >> * Argument passing between unittest methods. For example, if a test
> >>method were defined as testFoo(self, x, y), the two-tuple returned from
> >>setUp() would be passed in as values for the arguments. Similarly for
> >>tearDown().
> >
> >
> >I'm not sure why this is better than having setUp set instance attributes?
> >
>
> Shorter user code.
The difference seems minimal to me.
def setUp(self):
...
self.x = ...
self.y = ...
def testFoo(self):
...
self.assertEqual((self.y, self.x), foo(self.x, self.y))
def tearDown(self):
self.x.close()
vs.
def setUp(self):
...
x = ...
y = ...
return x, y
def testFoo(self, x, y):
...
self.assertEqual((y, x), foo(x, y))
def tearDown(self, x, y):
x.close()
It doesn't seem like a big deal either way, so why change it?
If a test* or a tearDown method find prepending "self." to be too unwieldy,
they always have the option of doing "x = self.x".
Also, what would happen if setUpClass and setUp both returned some values?
Using instance variables, there's no ambiguity.
-Andrew.
More information about the Twisted-Python
mailing list