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

Monsensical cannot-enumerate-pytest-fixtures error #68

Open
stdedos opened this issue May 23, 2024 · 1 comment
Open

Monsensical cannot-enumerate-pytest-fixtures error #68

stdedos opened this issue May 23, 2024 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@stdedos
Copy link
Collaborator

stdedos commented May 23, 2024

I'm eager to reproduce this if I can. I cloned scriv and ran python -m tox -e quality and it passed, without any output suggesting the scriv command ran.

I ran without tox as pylint src/scriv tests docs setup.py after installing pylint_pytest, and with pytest 7.4.2, and the files linted, although they threw lots of errors like:

************* Module scriv.util
src/scriv/util.py:12:0: E0401: Unable to import 'click_log' (import-error)
************* Module scriv.cli
src/scriv/cli.py:6:0: E0401: Unable to import 'click_log' (import-error)
************* Module scriv.linkcheck
src/scriv/linkcheck.py:7:0: E0401: Unable to import 'markdown_it' (import-error)
...
************* Module tests.test_ghrel
tests/test_ghrel.py:1:0: F6401: pylint-pytest plugin cannot enumerate and collect pytest fixtures. Please run `pytest --fixtures --collect-only tests/test_ghrel.py` and resolve any potential syntax error or package dependency issues. stdout: . stderr: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_pytest/config/__init__.py:324: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse
ConftestImportFailure: ModuleNotFoundError: No module named 'responses' (from /Users/jwalls/scriv/tests/conftest.py)
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning
  config = pluginmanager.hook.pytest_cmdline_parse(
ImportError while loading conftest '/Users/jwalls/scriv/tests/conftest.py'.
tests/conftest.py:10: in <module>
    import responses
E   ModuleNotFoundError: No module named 'responses'
. (cannot-enumerate-pytest-fixtures)

Once I can reproduce, I'm happy to bisect the pylint or astroid changes that could be to blame. I wonder if knowing your installed version of pytest would help. Any other tips for reproducing would be appreciated. Thanks.

Originally posted by @jacobtylerwalls in #67 (comment)

@stdedos stdedos added this to the Release v2 milestone May 23, 2024
@stdedos stdedos added the bug Something isn't working label May 23, 2024
@stdedos stdedos self-assigned this May 23, 2024
@stdedos
Copy link
Collaborator Author

stdedos commented May 23, 2024

For completeness:

This is also a nice reproducer. I have been having a similar issue in a proprietary code that threw more or less the same cannot-enumerate-pytest-fixtures error.

I have been trying to troubleshoot it with https://github.com/pylint-dev/pylint-pytest/tree/playground/impr/cannot-enumerate-pytest-fixtures. In any case - I don't get how is it possible that the current environment "disappears" and neither requests nor this.namespace.package.sub.module "exist" anymore.

Funny thing is that, pytest alone is able to figure the issue out (no variant of pytest --fixtures --collect-only ... reveals any issue, nor does it fail pytest).

To be honest, I have been blocking v2 behind tl;dr this issue and pytest v8 😶‍🌫️ (my time being limited, and no progress in figuring out the logic behind this 😕)

ANY help is more than welcome 🙏 (from people that know how module discovery works? pytest internals?)

stdedos added a commit that referenced this issue May 23, 2024
Fixes #67 as a stop-gap measure
(and luckily gives me fuel to debug the dreaded `cannot-enumerate-pytest-fixtures` issue:
 #68)

Signed-off-by: Stavros Ntentos <[email protected]>
stdedos added a commit that referenced this issue May 23, 2024
Fixes #67 as a stop-gap measure
(and luckily gives me fuel to debug the dreaded `cannot-enumerate-pytest-fixtures` issue:
 #68)

Signed-off-by: Stavros Ntentos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant