Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

quality.testing

Avoid live HTTP clients in Python unit tests

requests/httpx/urllib calls in unit tests should be doubled or recorded.

#Metadata

Rule ID
py.testing.real-network-in-unit-test
Severity
medium
Confidence
0.66
Languages
python
Presets
recommended, strict
Stability
experimental
Applies to
block
Tags
python, rules-catalog, testing

#Why it matters

Live HTTP couples CI to the network and slows feedback.

#Remediation

Use responses/httpretty/pytest-httpserver or dependency-injected clients with fakes.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/python/py.testing.real-network-in-unit-test.rule.yaml.