-
-
Notifications
You must be signed in to change notification settings - Fork 356
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
Workaround for pytest issue #3542 #346
Conversation
Implements __eq__ and __ne__ methods on teh File object. If both objects are files, the paths are getting compared, if the other object is a string it's compared with the path directly.
Use six to ensure python 2.x compatibility
There seems to be a bug in pytest where metafunc.parametrize breaks fixture scope. By creating a fixture and parameterizing it indirectly scope can be maintained
Hi, thanks for the PR. Do you have some tests / example alongside your PR ? |
I used this to test the workaround test_fixtures.py: import pytest
@pytest.fixture(scope='module', params=[1, 2])
def fixture1(request):
print "fixture1, round: %i" % request.param
return request.param
@pytest.fixture(scope='module', params=[1, 2])
def fixture2(fixture1, request):
print "fixture3, round: %i" % request.param
return request.param + fixture1
@pytest.fixture(scope='module', params=[1, 2])
def fixture3(request):
print "fixture4, round: %i" % request.param
return request.param
class TestScope:
def test_host1(self, fixture2, host):
assert 1
def test_host2(self, fixture3, host):
assert 1 Output of pytest --setup-show test_fixtures.py
With the workaround:
|
Hi, sorry for having a long time before merging this. I wanted to be sure to not break something... Here's a sample test which reproduce the issue adressed in this PR (unfortunatelly, it cannot be added to the test suite since our import pytest
V = 0
@pytest.fixture(scope="module")
def f(host):
global V
V += 1
assert V == 1
@pytest.mark.parametrize("p", ["a", "b"])
def test_foo(host, f, p):
pass Merged, thanks for the PR ! |
There seems to be a bug in pytest (#3542) where metafunc.parametrize breaks
fixture scope. By creating a fixture and parameterizing it indirectly
scope can be maintained