Difference between revisions of "Python pytest"

From John Freier
Jump to: navigation, search
(Created page with "To run tests in a specific dir pytest path/to/dir To run tests in a specific file pytest path/to/test_file.py To run a specific test in a file pytest path/to/test_file...")
 
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
 
To run a specific test in a file
 
To run a specific test in a file
 
   pytest path/to/test_file.py::test_function
 
   pytest path/to/test_file.py::test_function
 +
 +
or
 +
 +
  pytest path/to/test_file.py -k 'test_name'
 +
 +
To show the print statements.
 +
  -s or --capture=no

Latest revision as of 18:35, 8 May 2024

To run tests in a specific dir

 pytest path/to/dir

To run tests in a specific file

 pytest path/to/test_file.py

To run a specific test in a file

 pytest path/to/test_file.py::test_function

or

 pytest path/to/test_file.py -k 'test_name'

To show the print statements.

 -s or --capture=no