10

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.

BlackVegetable
  • 12,594
  • 8
  • 50
  • 82
user2611836
  • 386
  • 4
  • 6
  • 17

2 Answers2

9

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

swati
  • 101
  • 1
  • 5
7

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

Oleksiy
  • 6,337
  • 5
  • 41
  • 58