Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 909
Richard Knop Avatar asked Apr 08 '26 08:04

Richard Knop


1 Answers

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.

like image 150
Ned Batchelder Avatar answered Apr 10 '26 20:04

Ned Batchelder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!