Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure python nosetests to run print() statements?

Tags:

python

nose

While I know that this can be done from the command line nosetests --nocapture test.py

I would like to know if is it possible to add code into test.py so that I can just type nosetests test.py without adding --nosecapture.

like image 958
user2611836 Avatar asked Oct 31 '13 17:10

user2611836


2 Answers

You can see the print statements by adding the -s flag to your terminal command. e.g.

$ nosetests -s test.py

-s, --nocapture

Don’t capture stdout (any stdout output will be printed immediately) [NOSE_NOCAPTURE].

Check the official document here

like image 194
swati Avatar answered Nov 12 '22 03:11

swati


You can do it by either defining environment NOSE_NOCAPTURE variable, creating .noserc or nose.cfg file in your home directory that will have something like:

[nosetests]
nocapture=1

or by passing arguments to nose directly in python when calling nose.run() as described in nose documentation

like image 33
Oleksiy Avatar answered Nov 12 '22 05:11

Oleksiy