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

Improve fixtures to not affect other tests #76

Closed
wants to merge 1 commit into from

Conversation

emontnemery
Copy link
Contributor

Make sure fixtures socket_disabled and socket_enabled do not affect other tests

@codeclimate
Copy link

codeclimate bot commented Sep 9, 2021

Code Climate has analyzed commit 8685da7 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Owner

@miketheman miketheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you help me understand how this was a problem, and why this solves it? Even better with a test suite that proves the problem!

@miketheman miketheman added enhancement New feature or request more-info-needed Further information is requested labels Sep 18, 2021
@emontnemery
Copy link
Contributor Author

emontnemery commented Sep 20, 2021

Example:

"""Example test."""
import socket

def test_1(socket_enabled):
    ...

def test_2():
    socket.socket()

This will pass:

pytest tests/disable_socket_test.py::test_2

This will fail on tests/disable_socket_test.py::test_2 because test_1 will disable sockets:

pytest tests/disable_socket_test.py

@emontnemery
Copy link
Contributor Author

@miketheman Do you still need some more clarifications for this PR?

@miketheman
Copy link
Owner

@emontnemery I'm actually working through the precedence logic - see #81 for more - so I'm holding off on changes to the fixture behavior right now until I get more of that done.

@miketheman
Copy link
Owner

@emontnemery I think that the changes in #90 should help here. would you mind testing the plugin from main branch out for your scenario? The test teardown now restores the true socket instead of trying to manipulate the state.

@emontnemery
Copy link
Contributor Author

Yes, the change from #90 does indeed seem to work fine 👍

@emontnemery emontnemery closed this Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request more-info-needed Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants