Common test splitting issues with pytest

If you are attempting to split your tests across containers with pytest and encountering issues, such as:

No timing found for "tests/commands/__init__.py"
No timing found for "tests/commands/test_1.py"
No timing found for "tests/commands/test_2.py"

There may be a few adjustments you need to make.

Are you setting a custom working_directory?

If so, you may need to adjust the file paths that are saving to your test metadata XML file. Alternatively, if you are able to, try working out of the standard working directory we set for a container to see if that helps (you can do this by removing any instances of working_directory in your test run job).

Where does your pytest.ini live?

To get test splitting to work correctly it needs to be in the root directory of where you are running the tests from. If it's not, you may need to run the following command before you test run command:

cp -f .circleci/resources/pytest_build_config.ini pytest.ini

The .circleci/resources/pytest_build_config.ini path may need to be replaced to point to where it's located in your project.

Are you setting the junit_family in your pytest.ini?

Check to see if you have something like junit_family=legacy set in your pytest.ini file. More information here:

https://docs.pytest.org/en/stable/_modules/_pytest/junitxml.html

Search for "families" to see the relevant information. 

Example project that correctly splits by timings

The following is a fork of our sample-python-cfd project that implements splitting:

https://github.com/nbialostosky/sample-python-cfd/blob/split-test/.circleci/config.yml

Example build showing proper test splitting:

https://app.circleci.com/pipelines/github/nbialostosky/sample-python-cfd/18/workflows/8b37bd45-ed19-42e1-8cc4-44401697f3fc/jobs/20

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.