[TIP] Struggling with nose-to-pytest config file

Skip Montanaro skip.montanaro at gmail.com
Tue May 1 06:52:58 PDT 2018


I'm moving from nose to pytest and am struggling a bit to get a
working/useful config file. I renamed .noserc to pytest.ini and didn't
change anything. Things seemed to work okay, but various bits of
functionality are missing (output's not verbose, doctests aren't run,
xunit/junit output not generated). I was a bit worried that it was ignoring
my config file (even though it reports finding it).

Here's one basic example. When I use --verbose on the command line, I get
the expected verbose output, one line per test. If I give

[pytest]
verbose=yes

in the ini file, I get no verbose output, just the one dot per test. I also
tried  verbosity=1 and verbosity=2 to no avail. In addition, none of those
three settings provoked an error message from pytest. Pytest never
complains about anything. It seems to silently ignore everything.

In general, it's not clear how I do the following:

1. Translate old .noserc settings into pytest-speak

2. Move settings off the command line into the config file. (I see the
addopts thing, but aren't there equivalent configuration settings for the
command line flags?)

Google failed me. I saw some blog posts about converting from nose to
pytest, but didn't see any discussion about the translation of
configuration settings. Does pytest have some kind of magic
"--generate-config" flag which will spit out a pytest.ini file with all the
default values?

Thanks,

Skip Montanaro



More information about the testing-in-python mailing list