29. Running pytest | Tests discovery | Decode result | test outcomes | Options | Rajiv

Опубликовано: 12 Октябрь 2024
на канале: The Python Gurukul
229
15

pytest can be run in several different ways:

pytest: With no arguments, pytest searches the local directory and subdirectories for tests.

pytest filename1 filename2 dirname...: Runs the tests in multiple named files and directory.

Test discovery refers to how pytest finds your test code and depends on naming:

Test files should be named test_something.py or something_test.py.
Test methods and functions should be named test_something.
Test classes should be named TestSomething.
The possible outcomes of a test function include: PASSED (.), FAILED (F), SKIPPED (s), XFAIL (x), XPASS (X), and ERROR (E).

The -v or --verbose command-line flag is used to reveal more verbose output.

The --tb=no command-line flag is used to to turn off tracebacks.