Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pytest not showing test results in the terminal window

I'm trying to run some tests by invoking the pytest command at the command line in a directory containing tests. At the end, however, I see only how many tests passed or failed, but I don't see which ones, or the traceback the failed tests produced (see screenshot below).

Before I was seeing these things, and I don't recall changing anything in Pytest's configuration. What could be the issue?

enter image description here

Update

What is even more strange is that when I run some of the test scripts which I'm quite sure were displayed to yield test failures when run with pytest individually, the tests pass:

kurt@kurt-ThinkPad:~/dev/clones6/ipercron-compose/test$ pytest test_api.py
====================== test session starts =======================
platform linux2 -- Python 2.7.12, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/kurt/dev/clones6/ipercron-compose/test, inifile: 
plugins: flask-0.10.0
collected 5 items 

test_api.py .....

==================== 5 passed in 4.20 seconds ====================
kurt@kurt-ThinkPad:~/dev/clones6/ipercron-compose/test$ pytest test_furion.py
====================== test session starts =======================
platform linux2 -- Python 2.7.12, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/kurt/dev/clones6/ipercron-compose/test, inifile: 
plugins: flask-0.10.0
collected 6 items 

test_furion.py ......

==================== 6 passed in 7.84 seconds ====================
kurt@kurt-ThinkPad:~/dev/clones6/ipercron-compose/test$ pytest test_furion2.py
====================== test session starts =======================
platform linux2 -- Python 2.7.12, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/kurt/dev/clones6/ipercron-compose/test, inifile: 
plugins: flask-0.10.0
collected 4 items 

test_furion2.py ....

=================== 4 passed in 12.91 seconds ====================

Could there be some kind of difference between calling the tests with the pytest command or the pytest [filename] command?

like image 504
Kurt Peek Avatar asked Feb 13 '17 10:02

Kurt Peek


1 Answers

You can use

pytest -h

to show all of the info about possible flags and options. But the eisiest way to add more info to your tests adding -v flag, --verbose increase verbosity.

pytest your_test.py -v

f.i. if you have print() statement in your tests adding -s shows all of the results while running.

pytest your_test.py -v -s
like image 63
Vova Avatar answered Oct 01 '22 00:10

Vova