Ticket #14 (Closed: fixed)
test generators for methods do not work
| Priority: | normal | Reporter: | guest |
|---|---|---|---|
| Severity: | normal | Assigned to: | jpellerin |
| Component: | nose | Status: | closed |
| Version: | 0.8.7.1 | Resolution: | fixed |
| Milestone: | 0.9a1 | Keywords: |
Description by guest:
Given the following testclass:
class TestSomething(object):
def setUp(cls):
cls.x = 5 print "setting up"
def test_1(self):
assert self.x == 4
def test_2(self):
assert self.x == 6
def test_3(self):
for x in (1,2,7):
yield self.check,x
def check(self,arg):
assert arg %7 ==0
Method test_3 does not function as a proper test generator. What should probably happen is:
1) test_3 generates three separate tests, just like regular test generators 2) Each of the three tests created by test_3 should get setUp() called when they're called.
Attachments
Changelog
Sat Mar 18 12:06:46 2006: Modified by jpellerin
- component changed from nose to nose:collector
- milestone set to 0.9
- version set to 0.9
- status changed from new to assigned
Sat Mar 18 12:11:25 2006: Modified by guest
- attachment added: core.py
Sat Mar 18 12:12:13 2006: Modified by guest
- attachment added: added_method_generators
Mon Mar 20 13:10:42 2006: Modified by guest
- component changed from nose:collector to nose
- version changed from 0.9 to 0.8.7.1
Mon Mar 20 13:11:16 2006: Modified by guest
- attachment added: new_generator_patch
Thu Mar 23 20:51:16 2006: Modified by jpellerin
- milestone changed from 0.9 to 0.9a1
This should roll up in the refactoring in #23.
Mon Apr 10 21:20:12 2006: Modified by jpellerin
Generator methods should match generator funcs in their output, that is, the description of the test should include the generator method name, not the yielded method name.
Mon Apr 10 21:51:13 2006: Modified by jpellerin
- resolution set to fixed
- status changed from assigned to closed
Added, with tests (more coverage needed), in [21]

The last patch I submitted had a problem doing the following:
class Testclass(object):
Namely, the generator method 'check' couldn't access instance attributes in the previous patch. The new patch 'new_generator_patch' fixes this. Essentially, the original patch was creating the generator methods from an instance that was getting thrown away, and not properly creating a new instance for each generator method.