Repository navigation
How to pass a variable between tests where the variable gets updated within each test. #11583
Replies: 4 comments 1 reply
|
Hi @PatrickFlaherty, Adding a variable to a module makes it global, this is how Python works and not related to pytest. However it is recommended for tests to not depend on one another, so it is not recommended in general for tests to generate and pass information to one another. |
|
As mentioned above, it is not advisable for tests to rely on each other. However, Here's a basic example to illustrate this, using a test class: If a test fails, dependent tests will be skipped. Notice: |
Uh oh!
There was an error while loading. Please reload this page.
How to pass a variable between tests where the variable gets updated within each test within a module?
I see I can use a namespace within the pytest framework.
If for example I use pytest.my_variable, does this become a global variable such that I need to worry about using the same variable name in other tests running in parallel?
Thanks in advance for any input,
Patrick
All reactions