-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Move requests_unixsocket import outside of UNIXSocketNotebookTestBase.fetch_url() #5769
Conversation
Hi @hrnciar - thank you for submitting this pull request. The reason for the lazy import is because server extension authors use this module as a library and moving the import to a broader scope was forcing them to unnecessarily install We added |
That makes perfect sense. What we are trying to accomplish is that a missing dependency in tests is not reported as If we cannot move the import to the module level. It might make sense to change the bare What do you think? |
I see value in that, but rather than potentially break existing reasons to wait, how about checking for |
6ab3cfc
to
f016886
Compare
@kevin-bates, I have updated PR with |
notebook/tests/launchnotebook.py
Outdated
except ModuleNotFoundError as error: | ||
raise ModuleNotFoundError(error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to recreate the error instance, let's just pass it on.
Also, could you please add a comment here, something somewhat generic like the following? This way folks can extend this except
clause as needed.
except ModuleNotFoundError as error: | |
raise ModuleNotFoundError(error) | |
except ModuleNotFoundError as error: | |
# Errors that should be immediately thrown back to caller | |
raise error |
f016886
to
63ee7ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look good to me - thank you.
Some tests were failing on Fedora due to missing import of
requests_unixsocket
. Because of bare exception inwait_until_alive()
function, it was difficult to understand where the problem lies.I would suggest moving the import to the beginning of the test file, so in case of missing module ImportError exception will be raised even before the tests are collected.
Another solution would be to replace exception in the
wait_until_alive()
function with more specific ones (eg.HTTPError
,ConnectionError
...) so it will wait only if an exception is related to currently starting notebook and nothing else (like ImportError in this case).