All syntax guides
Short, practical guides on programming syntax, language fundamentals, and the tools developers reach for every day.
3,965 guides across 14 topics
Topics
Popular guides
Most readLatest guides
Page 53 of 397Python Pytest Coverage with pytest-cov
Measure Python code coverage with pytest-cov: set thresholds, exclude selected code, and generate terminal, HTML, and XML reports.
Python Pytest: Run Specific Tests and Filters
Learn how to run specific pytest tests with node IDs, -k filters, markers, and combined selection to keep test runs focused.
Python pytest asyncio: Writing Async Tests
Learn to write and run async tests with pytest and asyncio: install pytest-asyncio, use async fixtures and markers, control event loop scope, and avoid common failure modes.
Python pytest setup/teardown vs fixtures: Which should you use?
Python pytest setup/teardown vs fixtures: Compare xunit-style setup/teardown methods with pytest fixtures to decide which approach improves test isolation, sharing, and maintainability.
pytest Fixtures: monkeypatch, tmp_path, caplog, and capsys
Learn how pytest's built-in monkeypatch, tmp_path, caplog, and capsys fixtures isolate tests, with examples for environment variables, files, logs, and stdout/stderr.
Python Pytest Exception Testing with pytest.raises
Use pytest.raises to assert exception types and messages in Python: inspect raised exceptions, parametrize test cases, and avoid common mistakes.
Python pytest marks: skip, skipif, and xfail
Use pytest's skip, skipif, and xfail markers to control test execution: skip a test unconditionally, skip when a condition is true, or mark a failing test as expected.
Using pytest.mark.parametrize for Parameterized Tests in Python
Learn how to use pytest.mark.parametrize to write parameterized tests in Python. Covers syntax, multiple arguments, fixtures, custom IDs, class/module-level use, and common pitfalls.
Python Pytest Fixtures Scope and conftest
Learn how pytest fixture scope controls setup frequency and how conftest.py shares fixtures across test files, including when widening scope is safe.
Python Pytest: Basic Tests, Assertions, and Test Discovery
Learn how to write basic pytest tests with plain assert statements, understand pytest test discovery rules, test exceptions and floating-point values, and run a subset of tests.