| import pytest | |
| # | |
| @pytest.fixture | |
| def my_fixture(): | |
| yield "hello" | |
| @pytest.fixture | |
| def ham(my_fixture ): | |
| return 42 | |
| def test_sample_test(my_fixture ): | |
| pass | |
| def test_ham(ham, my_fixture): | |
| ham.bit_length() # | |
| my_fixture.swapcase() # | |
| @pytest.mark.parametrize(('spam,eggs'), [(1,1), (2,3), (3,3)]) | |
| @pytest.mark.parametrize('first,second', [(1,1), (2,3), (3,3)]) | |
| def test_sample(spam ,eggs ,first ,second ): | |
| pass | |
| @pytest.mark.parametrize('first,second', [('a', 1), (1, 'a')]) | |
| def test_sample(first, second): | |
| first.bit_length() # | |
| first.format()# | |
| first.__xor__( )# | |
| second.bit_length() # | |
| second.format()# | |
| second.__xor__( )# | |
| def test_type(first, second:set): | |
| second.update()# | |
| class TestFoo1: | |
| @pytest.fixture | |
| def my_fixture(self): | |
| return 42 | |
| @pytest.fixture | |
| def another_fix(): pass | |
| class TestFoo2: | |
| @pytest.fixture | |
| def my_fixture(self): | |
| return {"D": 42 } | |
| @pytest.fixture | |
| def class_only_fixture(): return 1 | |
| def test_bar(self, my_fixture, ham , class_only_fixture ): | |
| pass | |
| # No completion for another: different class | |
| def test_foo(self, my_fixture, another_fix ): | |
| assert my_fixture.keys() | |
| # No completion, declated in class | |
| def test_bar(class_only_fix ): | |
| pass |