[py-svn] [hpk42/pytest] yield and funcarg don't mix (issue #227)

James Laska issues-reply at bitbucket.org
Thu Nov 15 16:40:07 CET 2012


--- you can reply above this line ---

New issue 227: yield and funcarg don't mix
https://bitbucket.org/hpk42/pytest/issue/227/yield-and-funcarg-dont-mix

James Laska:

This appears to be similar in spirit to the problem reported in issue #16

pytest doesn't yield properly when called within a function/method that uses generated func_args.

For example, the following test:

```
#!python

def pytest_funcarg__bar(request):
    return "bar"

def test_good():
    pass

def test_bad(bar):
    yield 'bad-func-yield', True

class Testitem(object):

    def test_foo(self, bar):
        yield 'bad-method-yield', True
```

Fails to yield as expected ...

```
#!python

============================================================================================= test session starts =============================================================================================
platform linux2 -- Python 2.7.3 -- pytest-2.3.3
plugins: xdist, mozwebqa
collected 1 items / 2 errors 

../../../../tmp/test_yield.py .

=================================================================================================== ERRORS ====================================================================================================
_______________________________________________________________________________ ERROR collecting ../../../../tmp/test_yield.py ________________________________________________________________________________
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/runner.py:121: in __init__
>               self.result = func()
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/main.py:366: in _memocollect
>       return self._memoizedcall('_collected', lambda: list(self.collect()))
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/main.py:287: in _memoizedcall
>           res = function()
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/main.py:366: in <lambda>
>   return self._memoizedcall('_collected', lambda: list(self.collect()))
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/python.py:494: in collect
>       for i, x in enumerate(self.obj()):
E           TypeError: test_bad() takes exactly 1 argument (0 given)
_______________________________________________________________________________ ERROR collecting ../../../../tmp/test_yield.py ________________________________________________________________________________
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/runner.py:121: in __init__
>               self.result = func()
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/main.py:366: in _memocollect
>       return self._memoizedcall('_collected', lambda: list(self.collect()))
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/main.py:287: in _memoizedcall
>           res = function()
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/main.py:366: in <lambda>
>   return self._memoizedcall('_collected', lambda: list(self.collect()))
/home/devel/jlaska/.python/lib/python2.7/site-packages/_pytest/python.py:494: in collect
>       for i, x in enumerate(self.obj()):
E           TypeError: test_foo() takes exactly 2 arguments (1 given)
====================================================================================== 1 passed, 2 error in 3.58 seconds ======================================================================================

```


--

This is an issue notification from bitbucket.org. You are receiving
this either because you are the owner of the issue, or you are
following the issue.



More information about the pytest-commit mailing list