Fixtures
Example
import pytest
@pytest.fixture
def fixtureName():
return 123
# can be used to return objects ect... when they are needed multiple times over
# it seems to be similar to a setup function but in function based tests
def test_1(fixtureName):
assert fixture > 0
def test_2(fixtureName):
assert fixture < 200
Globalise fixtures
- make a file called
conftest.py
- fill it with the fixtures
import pytest
@pytest.fixture
def fixtureName():
return 123