mardi 28 juillet 2020

Fixture order of execution in pytest

I'm new to using Pytest. I'm a little confused about what's the appropriate use of fixtures and dependency injection for my project. My framework is the following:

conftest.py

@pytest.fixture(scope="session")
def test_env(request):
//some setup here for the entire test module test_suite.py

@pytest.fixture(scope="function")
def setup_test_suite(test_env): 
//some setup that needs to be done for each test function
//eventually parameterize? for different input configuration


test_suite.py
def test_function(setup_test_suite)
//some testing code here
  1. What's the difference between putting the setup function in conftest.py or within the test suite itself?
  2. I want the setup of the testing environment to be done once, for the entire session. If setup_test_suite is dependent on test_env, will test_env execute multiple times?
  3. If I were to parameterize setup_test_suite, what would be the order of calling the fixtures?

Aucun commentaire:

Enregistrer un commentaire