Replies: 2 comments 4 replies
-
That output indeed seems unexpected. Could you please show the code you used for it? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When using fixtures scoped to session, I initially expected that all fixtures with a session scope would be executed before any test case (for setup) and after all test cases (for teardown). However, I didn't observe the expected behavior. In my first attempt, when I implemented each test case with its own fixture scoped=session, I found that the fixture was executed only for that specific test case. In my second attempt, I tried implementing all fixtures scoped in the file conftest.py i found this behavor :
INFO root:conftest.py:7 setup session 5
INFO root:conftest.py:15 setup session 4
INFO root:test_tca1_4.py:12 setup class 4
INFO root:test_tca1_4.py:19 function setup 4
INFO root:test_tca1_4.py:28 I'm a test method from a test class 4
INFO root:test_tca1_4.py:21 function Teardown 4
INFO root:test_tca1_4.py:14 teardown class 4
INFO root:conftest.py:17 teardown session 4
INFO root:conftest.py:10 teardown session 5
INFO root:conftest.py:7 setup session 5
INFO root:conftest.py:15 setup session 4
INFO root:test_tca1_5.py:24 setup module 5
INFO root:test_tca1_5.py:19 setup class 5
INFO root:test_tca1_5.py:30 function setup 5
INFO root:test_tca1_5.py:37 function setup 5.1
INFO root:test_tca1_5.py:45 I'm a test method from a test class 5
INFO root:test_tca1_5.py:39 function Teardown 5.1
INFO root:test_tca1_5.py:32 function Teardown 5
INFO root:test_tca1_5.py:21 teardown class 5
INFO root:test_tca1_5.py:26 teardown module 5
INFO root:conftest.py:17 teardown session 4
INFO root:conftest.py:10 teardown session 5
im using pytest version tested (7.2.0, 7.2.2, 8.0.0)
Could anyone help me understand the behavior of pytest and how I can ensure that pytest executes fixtures scoped at the session level only once, at the start of execution and at the end?
Beta Was this translation helpful? Give feedback.
All reactions