Справочные материалы

Examples


Configuration

Configure#pytest#testing using pyproject.toml:

[tool.pytest.ini_options] # mandatory section name
addopts = "-s --no-header --no-summary" # force cmd flags
testpaths = [ # what directories contain tests
    "tests",
]
pythonpath = [ # what to add to the python path
    "."
]

Useful Flags

  • -x: stop a first failure.
  • --pdb: start the Python debugger on failure.
  • -k <filter>: only discover tests that match the filter.
  • --ff: start with tests that failed in the previous run.
  • --nf: start with new files.
  • --sw: start from where it stopped the previous run.
  • --no-header / --no-summary: remove the big blobs of texts in the output.
  • --verbosity=x: from 0 to 3 levels of output granularity.
  • -m: прогнать только тесты с определенной меткой, которая устанавливается декоратором @pytest.mark.new, где new - имя метки.

📂 Frameworks | Последнее изменение: 31.08.2024 11:12