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

add example scripts for issue #519 #2207

Merged
merged 5 commits into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions testing/example_scripts/issue_519.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

import pytest
import pprint


def pytest_generate_tests(metafunc):
if "arg1" in metafunc.fixturenames:
metafunc.parametrize("arg1", ["arg1v1", "arg1v2"], scope="module")

if "arg2" in metafunc.fixturenames:
metafunc.parametrize("arg2", ["arg2v1", "arg2v2"], scope="function")


@pytest.fixture(scope="session")
def checked_order():
order = []

yield order
pprint.pprint(order)
assert (
order
== [
("testing/example_scripts/issue_519.py", "fix1", "arg1v1"),
("test_one[arg1v1-arg2v1]", "fix2", "arg2v1"),
("test_two[arg1v1-arg2v1]", "fix2", "arg2v1"),
("test_one[arg1v1-arg2v2]", "fix2", "arg2v2"),
("test_two[arg1v1-arg2v2]", "fix2", "arg2v2"),
("testing/example_scripts/issue_519.py", "fix1", "arg1v2"),
("test_one[arg1v2-arg2v1]", "fix2", "arg2v1"),
("test_two[arg1v2-arg2v1]", "fix2", "arg2v1"),
("test_one[arg1v2-arg2v2]", "fix2", "arg2v2"),
("test_two[arg1v2-arg2v2]", "fix2", "arg2v2"),
]
)


@pytest.yield_fixture(scope="module")
def fix1(request, arg1, checked_order):
checked_order.append((request.node.name, "fix1", arg1))
yield "fix1-" + arg1


@pytest.yield_fixture(scope="function")
def fix2(request, fix1, arg2, checked_order):
checked_order.append((request.node.name, "fix2", arg2))
yield "fix2-" + arg2 + fix1


def test_one(fix2):
pass


def test_two(fix2):
pass
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ rsyncdirs = tox.ini pytest.py _pytest testing
python_files = test_*.py *_test.py testing/*/*.py
python_classes = Test Acceptance
python_functions = test
norecursedirs = .tox ja .hg cx_freeze_source
norecursedirs = .tox ja .hg cx_freeze_source testing/example_scripts
xfail_strict=true
filterwarnings =
error
Expand Down