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

Check for existing breakpoints when asserting absent sys.gettrace #1518

Closed
tkcranny opened this issue Aug 27, 2018 · 2 comments · Fixed by #1564
Closed

Check for existing breakpoints when asserting absent sys.gettrace #1518

tkcranny opened this issue Aug 27, 2018 · 2 comments · Fixed by #1564
Labels
legibility make errors helpful and Hypothesis grokable tests/build/CI about testing or deployment *of* Hypothesis

Comments

@tkcranny
Copy link

While developing a new strategy for hypothesis, I've run into the case where the code can't be debugged, at least by simply running pytest in a debugger. This is due to an assert in the conftest file:

if not IN_COVERAGE_TESTS:
@pytest.fixture(scope=u'function', autouse=True)
def validate_lack_of_trace_function():
assert sys.gettrace() is None

Personally I'm not sure on the meanings behind its existence and operation, but via a chat with @Zac-HD, it came up that if the (coverage) tests have a breakpoint, then they should allow the tests to proceed.

@Zac-HD Zac-HD added tests/build/CI about testing or deployment *of* Hypothesis language: Python legibility make errors helpful and Hypothesis grokable labels Aug 27, 2018
@Zac-HD
Copy link
Member

Zac-HD commented Aug 27, 2018

The idea here is that we are testing that there is no trace function unless we are running everything under coverage in CI, to check that the internal use of coverage metrics isn't leaking.

As a developer experience thing, we should avoid raising AssertionError if an explicit trace function has been set by e.g. pdb.

@Zac-HD
Copy link
Member

Zac-HD commented Aug 30, 2018

# This condition is to allow contributors to run our test suite under a
# debugger, without giving up the check for a leaky coverage system in CI.
IN_LOCAL_DEBUGGER = all([
    sys.gettrace() is not None,  # probably needs to specify that it's not coverage either
    os.environ.get('CI') != 'true',  # We're never using a debugger in CI!
])

if not (IN_COVERAGE_TESTS or IN_LOCAL_DEBUGGER):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legibility make errors helpful and Hypothesis grokable tests/build/CI about testing or deployment *of* Hypothesis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants