-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2207 from RonnyPfannschmidt/fix/519
add example scripts for issue #519
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Example test scripts | ||
===================== | ||
|
||
|
||
The files in this folder are not direct tests, but rather example test suites that demonstrate certain issues/behaviours. | ||
|
||
In the future we will move part of the content of the acceptance tests here in order to have directly testable code instead of writing out things and then running them in nested pytest sessions/subprocesses. | ||
|
||
This will aid debugging and comprehension. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters