Replies: 1 comment 1 reply
-
Depends on what you mean by "test environment", is that something that is possible to change on a per-test basis in the same session, for example switching some environment variables? If so, you can define a fixture in your root Something like this: @pytest.fixture(autouse=True)
def setup_test_environment(request: pytest.FixtureRequest):
config = get_config_for_path(request.node.path)
if config:
apply_env_config(config)
yield
# In case you need to undo the configuration somehow:
if config:
undo_env_config(config) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm quite new to Pytest and I need to solve the following:
I have an all-test-global conftest.py which has a session fixture, which basically initializes the test environment.
I also have multiple PyTest Python files in different folders testing different submodules of the application. In the files I have loads of Pytests.
I need to be able to parameterize the test environment on a "folder" basis, e.g. every application submodule can have a different test environment parameterization that needs to be passed to the session fixture, so that the fixture code can alter its behavior based upon the received parameter.
I'd like to avoid creating conftest.pys in every submodule folder.
How can it be actually done?
Thanks,
Beta Was this translation helpful? Give feedback.
All reactions