Jul
08
2010

How to run a single unit test/unit test module with py.test

Note to self: It is actually possible to select a single test module or a single test function in py.test.

But passing the file name as argument to a py.test invocation selects only the doctest from that file (wtf!?). Instead, you need to call it like this:

1
2
$ py.test -k test_module    # to run the tests from test_module.py
$ py.test -k test_func      # to run tests having the function name test_func

This is documented in the section advanced test selection and running modes of the py.test documentation, although I fail to see how this is advanced.

tags: ,
posted in How-To, Python by admin

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Leave Your Comment

You must be logged in to post a comment.

 
Powered by Wordpress and MySQL. Theme by openark.org