Pytest: Deprecate "pytest_funcarg__" prefix for fixtures

Created on 27 Jun 2016  路  14Comments  路  Source: pytest-dev/pytest

Start to issue deprecation warnings when fixtures are declared using this legacy idiom, to be removed at some point later in time.

proposal

Most helpful comment

That might be useful indeed - and you should upgrade to pytest-cov 2.3.1 :wink:

All 14 comments

cc @obestwalter

Not sure if it's worth, as keeping support for this old form is simple enough too

i want to see this removed :) it complicates things as its not sanely layered

It's not explicitly deprecated yet. Shall we add a deprecation warning before 3.0? I just grepped through the code and there are loads of tests using it. Updating those tests to use the fixture decorator would be a nice low hanging fruit task.

OK, I think we should introduce a deprecation warning for 3.0 then. Added it to the Wiki.

done in #1714

For pytest_funcargs__, what is the alternative approach? Since some legacy code have this and I'm new to py.test.

Just replace this:

def pytest_funcargs__hello():
    ...

with:

@pytest.fixture
def hello():
    ...

:wink:

@nicoddemus after updating to 3.0.1, I started seeing the warning even though I don't use pytest_funcarg__ anywhere in my code (I only use new-style fixture decorators). Happy to share more info if needed鈥攁nd tbh, I haven't dug into why this is popping up for my fixtures.

Edit: well, this is embarrassing. It says it in the warning. My warning was due to pytest_cov. Sorry, folks, for the misinformation.

@nickdirienzo Can you show the full, exact warning you get?

@The-Compiler sure:

WC1 None pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0.  Please remove the prefix and use the @pytest.fixture decorator instead.

After quickly grepping for pytest_funcarg__cov, I learned that it's a fixture in pytest_cov's tests. Whoops. I wonder if it'd be helpful to provide the fully qualified name for the location of the fixture in question?

That might be useful indeed - and you should upgrade to pytest-cov 2.3.1 :wink:

Heh, thanks. 馃槃

I got this message with pytest_cov installed, even though my project wasn't using it. Upgrading pytest_cov made it go away.

Was this page helpful?
0 / 5 - 0 ratings