I'm new to testing with Pytest, and I've run into a minor but annoying hangup.
In the command line test session results, I see my tests passing, but the percentage shown is not 100%, for some tests.
With some aggressive logging, I was able to confirm that my tests are passing as expected.
My question is: what's the meaning of the percentage that is displayed for the collected tests?
Example:
platform win32 -- Python 3.7.0a4, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
rootdir: C:\api-check, inifile:
collected 5 items
test_Me.py ... [ 60%]
test_env.py .. [100%]
========================== 5 passed in 6.04 seconds ===========================
This is a makeshift progress bar.
It displays the "percentage of work" done so far -- most probably, total completed tests by the total number of tests to run (that it precalculated at the start).
If your tests ran for longer, you would probably see the number in the line changing as it crunches through the specific file.
It's one of the features included on Pytest, since version 3.3 (2017).
As my comrade @ivan_pozdeev mentioned, it's a progress indicator, indeed.
Here's an example, where you have 4 tests collected:
$ pytest test.py -v
================================ test session starts =============================
platform linux -- Python 3.6.7, pytest-4.4.0, py-1.8.0, pluggy-0.9.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/ivanleoncz/git/pysd
collected 4 items
test.py::test_active_services PASSED [ 25%]
test.py::test_enabled_services PASSED [ 50%]
test.py::test_is_enabled PASSED [ 75%]
test.py::test_is_active PASSED [100%]
============================== 4 passed in 0.55 seconds ==========================
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With