Repository navigation
refactor/fix: move logic into setup phase and correct order - #88
Merged
Merged
Conversation
miketheman
force-pushed
the
miketheman/refactor-autouse
branch
from
December 20, 2021 22:14
cff29a1 to
8f5fb28
Compare
miketheman
force-pushed
the
miketheman/refactor-autouse
branch
from
December 21, 2021 00:33
430ba8e to
fae0c2a
Compare
miketheman
marked this pull request as draft
December 21, 2021 16:39
miketheman
force-pushed
the
miketheman/refactor-autouse
branch
from
December 21, 2021 16:50
fae0c2a to
1b33d25
Compare
When the plugin started out, I didn't know how to use the `runtest_setup` phase, so I used an automatically-used fixture. Once the hook usage was introduced, I can now consolidate a lot of the behavior logic ion one place. Signed-off-by: Mike Fiedler <[email protected]>
May duplicate some of the other tests, but I wanted to make sure this was clear. I may refactor other tests later - it's unclear how to measure how many times a line is hit right now. Signed-off-by: Mike Fiedler <[email protected]>
The previous configuration allowed for `allow-hosts` to be passed without `--disable-socket` to implicitly activate blocking. This was confusing and inconsistent so we now require it to enable the global behavior. This introduces a little more complexity to the setup method, but is more clear as to what is actually happening. Signed-off-by: Mike Fiedler <[email protected]>
miketheman
force-pushed
the
miketheman/refactor-autouse
branch
from
December 21, 2021 21:28
1b33d25 to
e4fff1a
Compare
Signed-off-by: Mike Fiedler <[email protected]>
miketheman
force-pushed
the
miketheman/refactor-autouse
branch
from
December 21, 2021 23:21
103682a to
d99a622
Compare
Signed-off-by: Mike Fiedler <[email protected]>
|
Code Climate has analyzed commit d3d8e0f and detected 0 issues on this pull request. View more on Code Climate. |
miketheman
marked this pull request as ready for review
December 22, 2021 19:44
altendky
added a commit
to altendky/hamster-mcp
that referenced
this pull request
Mar 26, 2026
pytest-socket and pytest-homeassistant-custom-component both register
pytest_runtest_setup hooks via entry points. Entry-point discovery
order depends on filesystem iteration of site-packages, which is
non-deterministic on Linux. When pytest-socket's hook runs before the
HA plugin's hook, enable_socket() is called first and then immediately
overridden by disable_socket(), causing SocketBlockedError.
Replace the bare enable_socket marker with usefixtures('socket_enabled').
The fixture runs during fixture setup (after all hooks), so it
deterministically re-enables sockets regardless of hook ordering.
This matches how HA core itself avoids the problem (e.g. the
hass_client and hass_ws_client fixtures explicitly depend on
socket_enabled).
Upstream references:
- miketheman/pytest-socket#88
- miketheman/pytest-socket#125
- MatthewFlamm/pytest-homeassistant-custom-component#154
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the plugin started out, I didn't know how to use the
runtest_setupphase, so I used an automatically-used fixture.I've now removed the fixture, which may have had unintended side effects with other plugins or test suites.
I've also changed the ordering, to be more inline with the expected behaviors, as I laid out in https://github.com/miketheman/pytest-socket/discussions/81#discussion-3670981
I've added a bunch of tests that express the desired precedence behavior in a test module
tests/test_precedence.pyand all the existing tests pass as well 🎉 .This, and a few other bits, should lead to an 0.50.0 release.
Signed-off-by: Mike Fiedler [email protected]