erikbstack
erikbstack

Reputation: 13254

Why doesn't nosetests find anything?

I am switching from python's unittest framework to nosetests, trying to reuse my unittest.TestCases

After cding into my tests package I started nosetests as described on their homepage:

./test/$ nosetests

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

Why do I need to specify each module to have nose discover its tests like in the following example?

./test/$ nosetests test_all.py
.......
----------------------------------------------------------------------
Ran 7 tests in 0.002s

OK

Also running the tests one folder above doesn't change anything.

./tests/$ cd ..
./$ nosetests

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

Upvotes: 14

Views: 4960

Answers (3)

Shubham Chaudhary
Shubham Chaudhary

Reputation: 51143

In my case I had following line at the end of the test files:

unittest.main()

Removing this from all my tests solved my issue.

Upvotes: 1

jpellerin
jpellerin

Reputation: 341

I can see in your repo that at least some of the files are executable, so that is at least part of the problem. By default, nose won't collect those: it's trying to avoid running scripts that might do something destructive on import. Try the --exe flag, or removing the executable bit from the test files.

Upvotes: 16

Julian
Julian

Reputation: 3429

You need to be in the directory above that if you want nose to run all the tests in that package.

Upvotes: 1

Related Questions