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

fix: disable console history in tests #882

Merged
merged 1 commit into from Jul 17, 2022
Merged

fix: disable console history in tests #882

merged 1 commit into from Jul 17, 2022

Conversation

ghost
Copy link

@ghost ghost commented Jul 15, 2022

What I did

Prevents IPython from spawning history collection threads when running the test suite

fixes: #881

How I did it

Add an auto-used fixture to patch an APE_TESTING environment variable in while testing. The IPython embedded instance launches with history disabled if this environment variable is set.

How to verify it

If the tests weren't failing from "too many open files", you can change the soft limit on your machine with this.

$ ulimit -n  # check current value so you can restore it later
...
$ ulimit -Sn 256  # set value to what was default in #881's repro steps
$ pytest tests/integration

This should produce a failure without these changes

Checklist

  • All changes are completed
  • New test cases have been added
  • Documentation has been updated

@ghost ghost requested review from fubuloubu, antazoey and NotPeopling2day July 15, 2022 21:26
Comment on lines -115 to -117
except io.UnsupportedOperation:
# Likely running in tests
pass
Copy link
Author

Choose a reason for hiding this comment

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

This seemed to only arise from running the test suite, so I opted to change up enabling the fault handler only when we aren't testing (i.e. have the test env set)

IPython.embed(colors="Neutral", banner1=banner, user_ns=namespace)
from traitlets.config import Config

config = Config()
Copy link
Author

Choose a reason for hiding this comment

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

Is it safe to assume an empty config when not environ.get("APE_TESTING") or should I have two separate paths and not provide the config kwarg at all if the env var isn't set?

fubuloubu
fubuloubu previously approved these changes Jul 15, 2022
Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

Very good contribution!

tests/conftest.py Show resolved Hide resolved
@ghost ghost requested a review from fubuloubu July 16, 2022 20:09
@fubuloubu fubuloubu merged commit 97c61d2 into ApeWorX:main Jul 17, 2022
@ghost ghost deleted the fix/disable-console-history-in-tests branch July 17, 2022 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integration tests open too many file descriptors
1 participant