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

No module named 'pytest' #371

Closed
JosephTLyons opened this issue Apr 21, 2023 · 2 comments
Closed

No module named 'pytest' #371

JosephTLyons opened this issue Apr 21, 2023 · 2 comments

Comments

@JosephTLyons
Copy link

JosephTLyons commented Apr 21, 2023

I think this is a user error, because I've had Ward working before, but for some reason, it's now complaining about pytest not being found. Does Ward expect the user to have this installed on their system or am I doing something incorrect here?

(virtual_environment) josephlyons@Josephs-MacBook-Pro key-bindings % ward
Traceback (most recent call last):
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/bin/ward", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/lib/python3.11/site-packages/ward/_run.py", line 200, in test
    modules = load_modules(mod_infos)
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/josephlyons/Work/docs/script/key-bindings/virtual_environment/lib/python3.11/site-packages/ward/_collect.py", line 152, in load_modules
    m.__loader__.exec_module(m)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/josephlyons/Work/docs/script/settings/virtual_environment/lib/python3.11/site-packages/numpy/tests/test_ctypeslib.py", line 2, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'
@darrenburns
Copy link
Owner

When you run ward it has to find tests, so it recursively searches directories for Python files. Since your virtual env is in the same directory, it looks in there and finds a lots of Python files and loads them to find tests.

If you explicitly pass the path to ward with ward --path path/to/src then it should avoid this issue. I suspect renaming your virtualenv folder to .venv might also work - I think ward specifically ignores that folder name as it's a common convention (could be wrong on that though).

@JosephTLyons
Copy link
Author

Awesome. --path . here worked, but I might rename the virtual environment as well. Appreciate the help here.

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

No branches or pull requests

2 participants