diff options
author | Prabhu Ramachandran | 2017-02-22 14:56:35 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2017-02-22 14:56:35 +0530 |
commit | d5c20e445b193fad5cb4339f00e11212fdd39c0a (patch) | |
tree | 94425bf5693fd7797fe128678614b4de364b0df9 /testing/code/test_fixtures.py | |
parent | ba725c5af9ac1c7064211589ff561fb79f3853b4 (diff) | |
download | python-workshops-d5c20e445b193fad5cb4339f00e11212fdd39c0a.tar.gz python-workshops-d5c20e445b193fad5cb4339f00e11212fdd39c0a.tar.bz2 python-workshops-d5c20e445b193fad5cb4339f00e11212fdd39c0a.zip |
Add basic slides for workshop on pytest.
Diffstat (limited to 'testing/code/test_fixtures.py')
-rw-r--r-- | testing/code/test_fixtures.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/code/test_fixtures.py b/testing/code/test_fixtures.py new file mode 100644 index 0000000..4676509 --- /dev/null +++ b/testing/code/test_fixtures.py @@ -0,0 +1,51 @@ +import pytest + + +@pytest.fixture +def my_fixture(): + print('my_fixture') + + +def test_foo(my_fixture): + print('runing test') + + +@pytest.fixture +def fix1(): + print('fix1') + yield + # Cleanup + print('Good bye: fix1') + + +def test_fix1(fix1): + print('Running test_fix1') + + +@pytest.fixture +def fix2(my_fixture): + yield + # Cleanup + print('Good bye: fix2') + + +def test_fix2(fix2): + print('Running test_fix2') + +@pytest.fixture +def some_data(my_fixture): + print('some_data fixture') + yield {'a': 1, 'b': 2} + # Cleanup + print('Good bye: fix2') + + +def test_some_data(some_data): + print(some_data) + print('Running test_fix2') + + + +@pytest.mark.usefixtures('fix1', 'fix2') +def test_foo(): + print('Running test_foo') |