-
Notifications
You must be signed in to change notification settings - Fork 37
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
--snapshot-default-extension
doesn't support pytest 7 pythonpath
#719
Comments
Are you interested in contributing a fix? I copied your test from your branch to #731 |
I am interested! My instinct was that the issue might be more architectural, and outside the scope of a first time contributor. That Syrupy's choice of hooks into pytest occur early for a different feature, but too early for pytest core's |
Ok, there is hope. The unexpected "does not exist" error is raised during pytest's plugin discovery's command line parsing. This suggests to me two solutions.
I'm looking into the latter. I'm trying out removing the code from this comment from #667. Do you remember why the eager import was necessary? Was it for DX, to fail fast with one failure, before test subprocesses try to import the module and spam the user with multiple failures? |
--snapshot-default-extension
doesn't support pytest 7 --pythonpath
--snapshot-default-extension
doesn't support pytest 7 pythonpath
* test: add coverage for bug #719 * fix: defer snapshot default extension import Fixes unable to use pytest's `pythonpath` option with this project's `--snapshot-default-extension` option. Does cause extension import errors to raise later than CLI argument parsing, and therefore emit on stdout, instead of stderr. --------- Co-authored-by: Noah Negin-Ulster <noah.negin-ulster@tophatmonocle.com>
🎉 This issue has been resolved in version 4.0.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Describe the bug
--snapshot-default-extension
doesn't support pytest 7'spythonpath
configuration option, for pytest-only additions to the Python path.For my project, I'm using
--snapshot-default-extension
so the right extension and serializer are in place, before Syrupy begins its reporting. My Syrupy extensions are for tests only, so they live outside of my src/ folder. Only the src/ folder of my project seems to be on the default Python path. So when running tests, I need to tell Syrupy about my extensions, somehow. I'd love to use the vanillapytest
command directly, configured in pyproject.toml, without having to pass a customPYTHONPATH
topytest
every time.To reproduce
See my branch, john-kurkowski/syrupy#default-extension-pythonpath. In the final commit, https://github.com/john-kurkowski/syrupy/commit/ea9779371583253c03b0bdf47c09ca6f5526d909, switching from modifying
sys.path
to setting pytest's--pythonpath
breaks 2/3 of the branch's test cases. EDIT: pytest'spythonpath
an INI configuration option, not CLI.Expected behavior
Tests in my branch should pass.
Environment:
Workaround
Set
PYTHONPATH
prior to invoking the pytest CLI.The text was updated successfully, but these errors were encountered: