nose-devs/nose — Issue #478: @attr is ignored on yielded tests
Author: anshumanb
Created: 2011-12-18 06:40:12+00:00
State: open

**What steps will reproduce the problem?**

With this in demo.py:

from nose.plugins.attrib import attr

def test_attr_with_yield():
for i in range(3):
yield nothing

@attr('myattr')
def nothing():
assert True

Run

nosetests -v -a 'myattr' demo.py
nosetests -v -a '!myattr' demo.py

**What is the expected output? What do you see instead?**

Expected case 1 to run 3 tests.
Expected case 2 to run 0 tests.

Saw case 1 run 0 tests.
Saw case 2 run 3 tests.

``-a 'myattr'`` should have included all the tests, while ``-a '!myattr'`` should have ignored it.

If i use ``@attr('myattr')`` on the generator function, the yielded functions have the attribute attached to them. I was using a custom decorator for each yielded test, which was automatically assigning the attribute using ``attr``, but stopped working when I started using generator functions.

**What version of the product are you using? On what operating system?**

nosetests version 1.1.2 on Arch Linux inside a virtualenv ``--no-site-packages``.