Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List available tests with py.test

I can't find a way to list the tests which I can call with py.test -k PATTERN

How can I see the list of the available tests?

like image 789
guettli Avatar asked Jan 30 '14 11:01

guettli


People also ask

How do I run multiple tests in pytest?

Run Multiple Tests From a Specific File and Multiple Files To run all the tests from all the files in the folder and subfolders we need to just run the pytest command. This will run all the filenames starting with test_ and the filenames ending with _test in that folder and subfolders under that folder.

Can pytest run unittest tests?

pytest supports running Python unittest -based tests out of the box. It's meant for leveraging existing unittest -based test suites to use pytest as a test runner and also allow to incrementally adapt the test suite to take full advantage of pytest's features.

What is py testing?

Pytest is a testing framework based on python. It is mainly used to write API test cases. This tutorial helps you understand − Installation of pytest. Various concepts and features of pytest.


2 Answers

You can also use --collect-only, this will show a tree-like structure of the collected nodes. Usually one can simply -k on the names of the Function nodes.

like image 152
flub Avatar answered Sep 18 '22 14:09

flub


You should use the flag --collect-only. If you are using pytest 5.3.0 or newer use --co.

pytest 5.3.0+

pytest --co 

previous versions

pytest --collect-only 

You can use this flag among other flags, so in your case pytest --co -k PATTERN.

like image 34
lmiguelvargasf Avatar answered Sep 17 '22 14:09

lmiguelvargasf