-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixtures in case files can now be automatically imported using the **…
…experimental** `@parametrize_with_cases(import_fixtures=True)`. Fixes #193 Also, Fixed an issue where a case transformed into a fixture, with the same name as the fixture it requires, would lead to a `pytest` fixture recursion.
- Loading branch information
Sylvain MARIE
committed
Mar 24, 2021
1 parent
c7b942b
commit 97e155c
Showing
8 changed files
with
180 additions
and
24 deletions.
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
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
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
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
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
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,24 @@ | ||
import pytest_cases | ||
|
||
|
||
from .test_issue_193_cases import case_two_positive_ints, case_two_positive_ints2 | ||
|
||
|
||
@pytest_cases.parametrize_with_cases("x", cases=case_two_positive_ints, debug=True, import_fixtures=True) | ||
def test_bar(x): | ||
assert x is not None | ||
|
||
|
||
@pytest_cases.parametrize_with_cases("x", cases=case_two_positive_ints2, debug=True, import_fixtures=True) | ||
def test_bar(x): | ||
assert x is not None | ||
|
||
|
||
@pytest_cases.parametrize_with_cases("x", debug=True, import_fixtures=True) | ||
def test_foo(x): | ||
assert x is not None | ||
|
||
|
||
@pytest_cases.parametrize_with_cases("x", debug=True, import_fixtures=True) | ||
def test_bar(x): | ||
assert x is not None |
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,15 @@ | ||
# We make sure that two files requiring the same cases files and importing fixtures can work concurrently | ||
import pytest_cases | ||
|
||
|
||
from .test_issue_193_cases import case_two_positive_ints, case_two_positive_ints2 | ||
|
||
|
||
@pytest_cases.parametrize_with_cases("x", cases=case_two_positive_ints, debug=True, import_fixtures=True) | ||
def test_bar(x): | ||
assert x is not None | ||
|
||
|
||
@pytest_cases.parametrize_with_cases("x", cases=case_two_positive_ints2, debug=True, import_fixtures=True) | ||
def test_bar(x): | ||
assert x is not None |
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,16 @@ | ||
import pytest_cases | ||
|
||
|
||
@pytest_cases.fixture | ||
def two_positive_ints(): | ||
return 1, 2 | ||
|
||
|
||
def case_two_positive_ints(two_positive_ints): | ||
""" Inputs are two positive integers """ | ||
return two_positive_ints | ||
|
||
|
||
def case_two_positive_ints2(two_positive_ints): | ||
""" Inputs are two positive integers """ | ||
return two_positive_ints |