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

docs: add details on fixture scope #61

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ or for whole test run
[pytest]
addopts = --allow-hosts=127.0.0.1,127.0.1.1

Frequently Asked Questions
==========================

Q: Why is network access disabled in some of my tests but not others?

A: pytest's default fixture scope is "function", which ``socket_enabled`` uses.
If you create another fixture that creates a socket usage that has a "higher"
instantiation order, such as at the module/class/session, then the higher
fixture will be resolved first, and won't be disabled during the tests.
Read more in `this excellent example
<https://github.com/miketheman/pytest-socket/issues/45#issue-679835420>`_ and
more about `pytest fixture order here <https://docs.pytest.org/en/stable/fixture.html#fixture-instantiation-order>`_.

This behavior may change in the future, as we learn more about pytest fixture
order, and what users expect to happen.

Contributing
------------
Expand Down