Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

staticmethod tests don't work with fixtures #2699

nicoddemus opened this issue Aug 17, 2017 · 0 comments

staticmethod tests don't work with fixtures #2699

nicoddemus opened this issue Aug 17, 2017 · 0 comments


Copy link

@nicoddemus nicoddemus commented Aug 17, 2017

Original post by @ceridwen in this comment:

I was attempting to use this, and it doesn't seem to be working quite right with fixtures. Running the following code,

import pytest

def foo():
    return 'foo'

def test_foo(foo):
    assert foo == 'foo'

class TestFoo:
    def test_foo(foo):
        assert foo == 'foo'

Produces the following error:

pyfuncitem = <Function 'test_foo'>

    def pytest_pyfunc_call(pyfuncitem):
        testfunction = pyfuncitem.obj
        if pyfuncitem._isyieldedfunction():
            funcargs = pyfuncitem.funcargs
            testargs = {}
            for arg in pyfuncitem._fixtureinfo.argnames:
                testargs[arg] = funcargs[arg]
>           testfunction(**testargs)
E           TypeError: test_foo() missing 1 required positional argument: 'foo'

../../Library/Python/3.6/lib/python/site-packages/_pytest/ TypeError
======================= 1 failed, 1 passed in 0.32 seconds =======================

The first test_foo() function passes correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant