Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
-
Do do it i need to put tests in one file.. |
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
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, i want to group some tests and execute them together. Also want some code be done before and after this tests.
So i created fixture and use it in some tests but teardown code after yield execute after whole session, after test that not use this fixture. For example:
conftest.py:
@pytest.fixture(scope='session', autouse=False)
def example_f():
logging.info("BEFORE")
yield
logging.info("AFTER")
test_1.py:
import logging
def test_1(example_f):
logging.info("TEST 1")
test_2.py:
import logging
def test_2():
logging.info("TEST 2")
And here is execution output:
2022-04-21 19:04:59.050 [ INFO] BEFORE (conftest.py:51)
2022-04-21 19:04:59.051 [ INFO] TEST 1 (Test_1.py:3)
test_1 ✓ 50% █████
2022-04-21 19:04:59.058 [ INFO] TEST 2 (Test_2.py:3)
2022-04-21 19:04:59.058 [ INFO] AFTER (conftest.py:53)
test_2 ✓
But i want next behaviour:
2022-04-21 19:04:59.050 [ INFO] BEFORE (conftest.py:51)
2022-04-21 19:04:59.051 [ INFO] TEST 1 (Test_1.py:3)
2022-04-21 19:04:59.058 [ INFO] AFTER (conftest.py:53)
2022-04-21 19:04:59.058 [ INFO] TEST 2 (Test_2.py:3)
Beta Was this translation helpful? Give feedback.
All reactions