nose unittest discovery broken on python 3.8

Viewed 898

Upgraded from python 3.7 to 3.8 today. Unittest discovery in nose no longer works.

Simplified project layout

x:\proj\src\__init__.py
x:\proj\src\first.py
x:\proj\tests\__init.py
x:\proj\tests\testfirst.py

From project root x:\proj, run:

nosetests -v
-----------------------------------------------
Ran 0 tests in 0.016s

OK

Can only run unittests by specifying them, eg:

nosetests tests.testfirst
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

Platform

  • nosetests version 1.3.7
  • Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
1 Answers

Nose now requires you use the --traverse-namespace option when there are multiple packages. You can add this to the nosetests invocation, or to save yourself typing, add it to setup.cfg, eg:

[nosetests]
traverse-namespace=1
Related