Created
March 29, 2020 21:03
-
-
Save rooterkyberian/56ba54baefa11f5284dc576c20c2b86d to your computer and use it in GitHub Desktop.
pytest multiple modules
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
$ pytest test.py | |
========================================= test session starts ========================================== | |
platform linux -- Python 3.7.5, pytest-5.4.1, py-1.8.1, pluggy-0.13.1 | |
rootdir: CENSORED | |
collected 2 items | |
test.py FF [100%] | |
=============================================== FAILURES =============================================== | |
______________________________________ test_implementacja[pickle] ______________________________________ | |
implementacja = <module 'pickle' from '/usr/lib/python3.7/pickle.py'> | |
def test_implementacja(implementacja): | |
> assert implementacja.__name__ == "abc" | |
E AssertionError: assert 'pickle' == 'abc' | |
E - abc | |
E + pickle | |
test.py:12: AssertionError | |
_______________________________________ test_implementacja[math] _______________________________________ | |
implementacja = <module 'math' (built-in)> | |
def test_implementacja(implementacja): | |
> assert implementacja.__name__ == "abc" | |
E AssertionError: assert 'math' == 'abc' | |
E - abc | |
E + math | |
test.py:12: AssertionError | |
======================================= short test summary info ======================================== | |
FAILED test.py::test_implementacja[pickle] - AssertionError: assert 'pickle' == 'abc' | |
FAILED test.py::test_implementacja[math] - AssertionError: assert 'math' == 'abc' | |
========================================== 2 failed in 0.02s =========================================== |
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
import importlib | |
import pytest | |
@pytest.fixture(scope="module", params=["pickle", "math"]) | |
def implementacja(request): | |
return importlib.import_module(request.param) | |
def test_implementacja(implementacja): | |
assert implementacja.__name__ == "abc" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment