kiwicom/pytest-recording

[BUG] tests/test_blocking_network.py::test_block_network_with_allowed_hosts fail with no network (does not block DNS requests?))

mgorny opened this issue · 0 comments

mgorny commented

Describe the bug
When running the test suite in an environment without Internet access, I'm getting the following test failures:

FAILED tests/test_blocking_network.py::test_block_network_with_allowed_hosts[block_marker] - AssertionError: assert {'errors': 0,...pped': 0, ...} == {'errors': 0,...pped': 0, ...}
FAILED tests/test_blocking_network.py::test_block_network_with_allowed_hosts[block_cmd] - AssertionError: assert {'errors': 0,...pped': 0, ...} == {'errors': 0,...pped': 0, ...}
FAILED tests/test_blocking_network.py::test_block_network_with_allowed_hosts[vcr_cfg] - AssertionError: assert {'errors': 0,...pped': 0, ...} == {'errors': 0,...pped': 0, ...}

If I'm reading the output right, even though the requests were supposed to be blocked, requests attempts to resolve example.com and fails with NameResolutionError.

Full log: test-output.txt

To Reproduce
Steps to reproduce the behavior:

  1. Run tox -e py311 (or alike) to prepare the test env
  2. sudo unshare -n
  3. ifconfig lo up
  4. su - <regularuser>
  5. cd <pytest-recording-checkout>
  6. . .tox/py311/bin/activate
  7. python -m pytest

Expected behavior
Tests passing (i.e. no DNS requests should be made if network access is blocked).

Environment (please complete the following information):

  • OS: Gentoo Linux amd64
  • Python version: 3.11.6
  • pytest-recording version: 0.13.0 (85c3ffa)
  • pytest version: 7.4.2

Additional context
n/a