Код: Выделить всё
import pytest
@pytest.fixture(scope='function')
def fixture_function():
print('function')
@pytest.fixture(scope='class')
def fixture_class():
print('class')
@pytest.fixture(scope='module')
def fixture_module():
print('module')
@pytest.fixture(scope='package')
def fixture_package():
print('package')
@pytest.fixture(scope='session')
def fixture_session():
print('session')
class Test1:
def test1(
self,
fixture_function,
fixture_class,
fixture_module,
fixture_package,
fixture_session
):
pass
Код: Выделить всё
pytest -q -rP
Код: Выделить всё
$ pytest -q -rP
. [100%]
=============== PASSES ===============
____________ Test1.test1 _____________
_______ Captured stdout setup ________
session
package
module
class
function
1 passed in 0.10s
- В чем разница между функцией и классом, модуль, пакет и сеанс для областей фиксации в Pytest?
- Когда мне следует использовать области фиксации в Pytest?
Подробнее здесь: https://stackoverflow.com/questions/768 ... -in-pytest