【发布时间】:2021-03-26 13:39:57
【问题描述】:
鉴于以下简单的 Python 项目,
$ tree
.
├── Pipfile
├── Pipfile.lock
├── src
└── tests
├── test_foo.py
└── util.py
$ cat Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
ipython = "*"
pytest = "*"
[dev-packages]
[requires]
python_version = "3.9"
$ cat tests/util.py
FOO = 5
$ cat tests/test_foo.py
from tests.util import FOO
def test_foo():
assert FOO == 5
在test_foo 上使用pytest 和适当的pipenv --venv 运行PyCharm 调试器会产生以下错误:
Connected to pydev debugger (build 202.8194.15)
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tests.util'
【问题讨论】:
标签: python python-3.x pycharm ipython python-module