Search code examples
pythondjangonosetests

Cannot run tests with nosetests


I am trying to use nosetests to run all test cases inside my project.

I cd to my project directory:

cd projects/myproject

Then I do:

nosetests

Which outputs:

----------------------------------------------------------------------
Ran 0 tests in 0.001s

OK

Inside projects/myproject I have a package called Encode and inside the package I have Test directory with tests:

Encode/
    __init__.py
    Video.py
    Ffmpeg.py
    Test/
        VideoTest.py
        FfmpegTest.py

Why is nosetests not detecting my unit tests? All of my unit test classes extend unittest.TestCase.


Solution

  • From the nose docs:

    Any function or class that matches the configured testMatch regular expression ((?:^|[\b_\.-])[Tt]est) by default – that is, has test or Test at a word boundary or following a - or _) and lives in a module that also matches that expression will be run as a test.

    Your tests aren't being found because your filenames don't match the pattern. Change them to Video_Test.py, or Test_Video.py, for example. BTW: It's also odd that they have camelCase names like that, but that won't stop them from working.