Pab*_*dez 5 python testing directory-structure
我的代码是这样组织的:
app/sampling
??? __init__.py
??? filters.py
??? test
??? filters_test.py
Run Code Online (Sandbox Code Playgroud)
上filters.py有一些__init__.py下划线开头的导出函数(包含在中)和一些未导出的函数。
开启filters_test.py我可以轻松测试导出的功能,我可以像这样访问:
from app.sampling import exported_function
Run Code Online (Sandbox Code Playgroud)
(请注意,“ app”是我的PYTHONPATH的一部分)
但是,如果我尝试导入这样的私有函数:
from ..filters import _private_function
Run Code Online (Sandbox Code Playgroud)
这似乎可行,但随后在运行时:
SystemError: Parent module '' not loaded, cannot perform relative import
附加条款:
| 归档时间: |
|
| 查看次数: |
114 次 |
| 最近记录: |