You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having some trouble using python_path in the command line.
I am using
Python 3.10.6
pytest 7.3.1
I made an example case:
example
├── MyClass.py
└── app
└── test_pytest.py
# MyClass.py
class MyClass:
pass
# test_pytest.py
import MyClass
If inside ~/example/app I run
pytest -o python_path=../
I get the error
ImportError while importing test module '/home/ocanela/pytest/package/test_pytest.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../anaconda3/envs/py310/lib/python3.10/importlib/__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
test_pytest.py:1: in <module>
import MyClass
E ModuleNotFoundError: No module named 'MyClass'
Same result if I use pythonpath instead of python_path. However, if I create the file
# pytest.ini
[pytest]
pythonpath=../
inside ~/example/app, it seems to run without problems.
Not sure if that is me doing something wrong, or that is a bug related to #9636
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am having some trouble using python_path in the command line.
I am using
I made an example case:
If inside ~/example/app I run
pytest -o python_path=../
I get the error
Same result if I use pythonpath instead of python_path. However, if I create the file
inside ~/example/app, it seems to run without problems.
Not sure if that is me doing something wrong, or that is a bug related to #9636
I hope that makes sense, and thanks for any help.
Beta Was this translation helpful? Give feedback.
All reactions