I’m working with the pandas
codebase and using the _tester.py
module located at pandas/util/_tester.py
to execute tests. Specifically, I’m calling the pandas.test()
function to run the test suite. Here’s how I’m doing it:
import pandas
pandas.test()
I can run the same tests directly with a pytest
command, for example:
python3.12 -m pytest --cov=pandas --cov-report=term-missing --cov-branch pandas/tests/api/test_api.py::TestApi::test_api_indexers
Are these two approaches (pandas.test()
and running pytest
directly) functionally equivalent?
Does using pandas.test()
introduce any additional overhead compared to directly invoking pytest
? For example:
Does the wrapper preprocess or filter the test suite in any way?
Are there any significant differences in performance or the way results are handled?
In large test suites, would one approach be more efficient or recommended over the other?
.Thanks in advance!
These are 2 completely different depths of testing. Unit testing is not recursive by nature i.e. in your python project you should unit test only components, that you built, not dependencies of these components.
Pandas is your dependency in this case. pandas.test()
uses pytest – but it’s upstream dependency unit test. General approach with python projects is – you should trust your dependencies, and in general once you fix their version – complete behavior should be replicable regardless of installation, as long as all requirements are met (there are some edge cases to this rule – however it will cover you in 99,999…%).