Stefano Borini
Stefano Borini

Reputation: 143765

Unittests marked with @unittest.skip are not marked under nosetests

When one uses @unittest.skip and runs tests, generally the skipped tests are marked with a small s, and the tally is reported at the end.

If I run the tests with nosetests, the tests simply disappear, leaving no trace of their existence in the final report. I tried with --no-skip, but it didn't change anything.

How can I have the "s" marks and the total skipped while running under nose?

Upvotes: 2

Views: 441

Answers (2)

Oleksiy
Oleksiy

Reputation: 6567

Looks like you have to provide a reason for skipping a test:

from unittest import skip

@skip
def foo_test():
    pass

gives what you observed:

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

OK

while:

from unittest import skip

@skip("nose likes having good reasons")
def foo_test():
    pass

will give you:

foo_test.foo_test ... SKIP: nose likes having good reasons

----------------------------------------------------------------------
Ran 1 test in 0.003s

OK (SKIP=1)

Upvotes: 4

khampson
khampson

Reputation: 15296

I mark tests to be skipped in nose via the @nottest decorator (at the test method level), and they are marked with an S and listed in the number of skipped tests at the end.

To get that decorator you import thusly:

from nose.tools import nottest

Upvotes: 1

Related Questions