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

Fixture scope doesn't work when it is parametrized #1697

Closed
bubanoid opened this Issue Jul 4, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@bubanoid
Copy link

bubanoid commented Jul 4, 2016

Please look at the following tests

import pytest

ind = [0]


@pytest.fixture(scope="session")
def fixture_0(request):
    print('\n')
    ind[0] += 1


@pytest.mark.parametrize('fixture_0', ['smth'], indirect=True)
def test_1(fixture_0):
    print('test_1:  ind={ind}'.format(ind=ind[0]))


def test_2(fixture_0):
    print('test_2:  ind={ind}'.format(ind=ind[0]))

and their output:

test_1:  ind=1
test_2:  ind=2

however I expected to get the

test_1:  ind=1
test_2:  ind=1

I guess it is a bug. This issue is connected to the issue #634 See also another presentation of this issue: https://bitbucket.org/pytest-dev/pytest/issues/634/metafuncparametrize-overwrites-scope

@RonnyPfannschmidt

This comment has been minimized.

Copy link
Member

RonnyPfannschmidt commented Jul 4, 2016

as far as i can tell this is exactly related to #634

@Stranger6667

This comment has been minimized.

Copy link
Contributor

Stranger6667 commented Jul 26, 2016

After merging #1766 test above produces the following output:

collected 2 items

test_x.py::test_1[smth]

test_1:  ind=1
PASSED
test_x.py::test_2 test_2:  ind=1
PASSED

So, it is fixed as I see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.