On Tue, Dec 03, 2013 at 14:51 +1100, Brianna Laugher wrote:
On 26 November 2013 18:58, holger krekel <holger@merlinux.eu> wrote:
I use flakes and pep8 (pytest-flakes and pytest-pep8) and don't get this error. What you can immediately do but which is not pretty is to use the old naming scheme together with a decorator:
import pytest
@pytest.fixture def pytest_funcarg__somefixture(...): ...
This should avoid the pylint warning.
Ah, that's cool - I didn't realise that was possible.
However, it doesn't work the way you describe. :) Not sure if your description or the code is backwards!
At the moment (pytest-2.3.5) if I have two fixtures like this:
@py.test.fixture def pytest_funcarg__foo2(monkeypatch): return monkeypatch
def pytest_funcarg__foo3(monkeypatch): return monkeypatch
foo3 works (!). foo2 causes an assertion error on collection.
The code in parsefactories has a couple of if blocks, maybe one is inverted. :)
Right, it seems that when we introduced @pytest.fixture we decided you can either use the prefix or the marker. That could be lifted but i wonder if we should rather go for a different convention because pytest_funcarg__ is not a beautiful prefix. What do you think of pytest stripping the "__" prefix? @pytest.fixture def __foo2(monkeypatch): return monkeypatch This fixture would become accessible via the "foo2" name. Using "__foo2" would yield a lookup error and the error would indicate there is a "foo2" available. If you don't like it, any other suggestions?
Don't know if this is a good idea, but you could tell if it was new style/old style based on if the parameter was 'request' or nothing/other fixtures.
There is no difference between old-style and @pytest.fixture(scope="function") and the presence of "request" indicates nothing particular. best, holger
cheers Brianna
-- They've just been waiting in a mountain for the right moment: http://modernthings.org/