Repaso
EspaƱol
TestingCoreTST-25

How does pytest find tests by default?

Options

  1. It runs every Python file in the project folder
  2. Files test_*.py, functions test_*, classes Test* (Correct option)
  3. Only files in a folder that is named pytest
  4. You must register each test by hand in a file

Answer

Files named test_*.py or *_test.py, functions starting with test_, and classes starting with Test

Why

Run pytest in your project and it searches the folders for files named test_something.py, then runs every function whose name starts with test_.

If you name a function check_login(), pytest will silently ignore it.

Useful options: pytest -k login (only matching names), pytest -x (stop at first failure), pytest -v (verbose).

Remember

pytest runs test_*.py files and test_* functions.

Key terms

Practice this question in Repaso