pytest is a Python testing framework for discovering and running assertion-based tests. In infrastructure work, it verifies generated configuration without requiring configuration files or a live deployment. section 6.0 section 6.2.1
Use pytest to test infrastructure configuration through small, repeatable checks:
- Name test files and test functions with the test_ prefix so pytest discovers them. section 6.2.1
- Test factory functions that generate network and subnet configuration, including names, subnet counts, and IP ranges. section 6.2.1
- Create fixtures for known configurations and reuse them across tests instead of repeating resource construction or parsing. section 6.2.1
- Choose tests selectively: automated checks provide durable documentation, but redundant tests increase maintenance effort. section 6.0
Running network configuration tests
A file named test_network.py can collect three tests for a generated network object. Running `pytest test_network.py` reports the session, collects three items, and can finish with `3 passed`.










