Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify a single test in a file with nosetests?

I have a file called test_web.py containing a class TestWeb and many methods named like test_something().

I can run every test in the class like so:

$ nosetests test_web.py  ... ====================================================================== FAIL: checkout test ---------------------------------------------------------------------- Traceback (most recent call last):   File "/Users/me/path/here/test_web.py", line 187, in test_checkout ... 

But I can’t seem to run individual tests. These give me “No such test” errors when run in the same PWD:

$ nosetests test_web.py:test_checkout $ nosetests TestWeb:test_checkout 

What could be wrong here?

like image 260
opstastic Avatar asked Jul 02 '12 00:07

opstastic


People also ask

Which command is used to run nose tests?

Basic Usage nose can be integrated with DocTest by using with-doctest option in athe bove command line. The result will be true if the test run is successful, or false if it fails or raises an uncaught exception. nose supports fixtures (setup and teardown methods) at the package, module, class, and test level.

What is Django nose?

django-nose provides all the goodness of nose in your Django tests, like: Testing just your apps by default, not all the standard ones that happen to be in INSTALLED_APPS. Running the tests in one or more specific modules (or apps, or classes, or folders, or just running a specific test)


1 Answers

You must specify it like so: nosetests <file>:<Test_Case>.<test_method>, or

nosetests test_web.py:TestWeb.test_checkout 

See the docs

like image 165
Will Avatar answered Sep 18 '22 15:09

Will