Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mgorny opened this issue Oct 22, 2023 · 0 comments

Comments

@mgorny
Copy link

mgorny commented Oct 22, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants