Skip to content

Instantly share code, notes, and snippets.

@rooterkyberian
Created March 29, 2020 21:03
Show Gist options
  • Save rooterkyberian/56ba54baefa11f5284dc576c20c2b86d to your computer and use it in GitHub Desktop.
Save rooterkyberian/56ba54baefa11f5284dc576c20c2b86d to your computer and use it in GitHub Desktop.
pytest multiple modules
$ 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 ===========================================
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