You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a detailed description of the bug or problem you are having
I have two files - test_file1.py & test_file2.py.
In each of them a test class TestFile1 & TestFile2 and in each of the classes I have two tests.
In class TestFile2 I have a static meth which I import to test_file1.py
When running pytest on test_file1.py it collects 4 tests; two of them are correct and two are some storage combination.
output of pip list pip_list.txt
` from the virtual environment you are using
pytest and operating system versions cat /proc/version
Linux version 5.4.72-microsoft-standard-WSL2 (oe-user@oe-host) (gcc version 8.2.0 (GCC)) assert reinterpretation fails for some code layouts #1 SMP Wed Oct 28 23:40:43 UTC 2020 pytest --version
This is pytest version 5.2.4, imported from /usr/local/lib/python3.7/dist-packages/pytest.py
setuptools registered plugins:
allure-pytest-2.8.16 at /usr/local/lib/python3.7/dist-packages/allure_pytest/plugin.py
pytest-env-0.6.2 at /usr/local/lib/python3.7/dist-packages/pytest_env/plugin.py
pytest-ordering-0.6 at /usr/local/lib/python3.7/dist-packages/pytest_ordering/init.py
pytest-timeout-1.4.2 at /usr/local/lib/python3.7/dist-packages/pytest_timeout.py
pytest-repeat-0.8.0 at /usr/local/lib/python3.7/dist-packages/pytest_repeat.py
container@docker-desktop:/home/ubuntu/workspace/test_qemu_container/hips-automation/sandbox/pytest_collect_issue$
importloggingfrom .test_file2importTestFile2classTestFile1(object):
@staticmethoddefmethod_in_file1():
logging.warning("Running test {}".format("method_in_file1"))
TestFile2.method_in_file2()
deftest_1_in_file1(self):
logging.warning("Running test {}".format(self.__class__.__name__))
deftest_2_in_file1(self):
logging.warning("Running test {}".format(self.__class__.__name__))
the content of test_file2.py:
importloggingclassTestFile2(object):
@staticmethoddefmethod_in_file2():
logging.warning("Running test {}".format("method_in_file2"))
deftest_1_in_file2(self):
logging.warning("Running test {}".format(self.__class__.__name__))
deftest_2_in_file2(self):
logging.warning("Running test {}".format(self.__class__.__name__))
Running the command
pytest -o log_cli=true test_file1.py The output
============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.7.3, pytest-5.2.4, py-1.9.0, pluggy-0.13.1
rootdir: /home/ubuntu/workspace/test_qemu_container/hips-automation/sandbox/pytest_collect_issue
plugins: allure-pytest-2.8.16, env-0.6.2, ordering-0.6, timeout-1.4.2, repeat-0.8.0
collected 4 items
test_file1.py::TestFile1::test_1_in_file1
------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------
WARNING root:test_file1.py:13 Running test TestFile1
PASSED [ 25%]
test_file1.py::TestFile1::test_2_in_file1
------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------
WARNING root:test_file1.py:16 Running test TestFile1
PASSED [ 50%]
test_file1.py::TestFile2::test_1_in_file2
------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------
WARNING root:test_file2.py:11 Running test TestFile2
PASSED [ 75%]
test_file1.py::TestFile2::test_2_in_file2
------------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------------
WARNING root:test_file2.py:14 Running test TestFile2
PASSED [100%]
=============================================================================================== 4 passed in 0.12s ================================================================================================
test_file1.py::TestFile2::test_2_in_file2 & test_file1.py::TestFile2::test_1_in_file2 should not be there
I think if class TestFile2 had an autouse fixture it will also run it.
Please let me know if I am doing something wrong.
Thank you.
The text was updated successfully, but these errors were encountered:
I don't see what's unexpected about this. You import TestFile2, so from pytest's point of view, it's just like the TestFile2 class was in test_file1.py as well.
a detailed description of the bug or problem you are having
I have two files - test_file1.py & test_file2.py.
In each of them a test class TestFile1 & TestFile2 and in each of the classes I have two tests.
In class TestFile2 I have a static meth which I import to test_file1.py
When running pytest on test_file1.py it collects 4 tests; two of them are correct and two are some storage combination.
output of
pip list
pip_list.txt
` from the virtual environment you are using
pytest and operating system versions
cat /proc/version
Linux version 5.4.72-microsoft-standard-WSL2 (oe-user@oe-host) (gcc version 8.2.0 (GCC)) assert reinterpretation fails for some code layouts #1 SMP Wed Oct 28 23:40:43 UTC 2020
pytest --version
This is pytest version 5.2.4, imported from /usr/local/lib/python3.7/dist-packages/pytest.py
setuptools registered plugins:
allure-pytest-2.8.16 at /usr/local/lib/python3.7/dist-packages/allure_pytest/plugin.py
pytest-env-0.6.2 at /usr/local/lib/python3.7/dist-packages/pytest_env/plugin.py
pytest-ordering-0.6 at /usr/local/lib/python3.7/dist-packages/pytest_ordering/init.py
pytest-timeout-1.4.2 at /usr/local/lib/python3.7/dist-packages/pytest_timeout.py
pytest-repeat-0.8.0 at /usr/local/lib/python3.7/dist-packages/pytest_repeat.py
container@docker-desktop:/home/ubuntu/workspace/test_qemu_container/hips-automation/sandbox/pytest_collect_issue$
minimal example if possible
test_file2.py.txt
test_file1.py.txt
the content of test_file1.py:
the content of test_file2.py:
Running the command
pytest -o log_cli=true test_file1.py
The output
test_file1.py::TestFile2::test_2_in_file2 & test_file1.py::TestFile2::test_1_in_file2 should not be there
I think if class TestFile2 had an autouse fixture it will also run it.
Please let me know if I am doing something wrong.
Thank you.
The text was updated successfully, but these errors were encountered: