- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 python 项目中,我有以下目录结构
├── cooccurrence
│ ├── cooccurrence.py
│ ├── __init__.py
├── README.md
└── tests
├── __init__.py
└── test_coccurrence.py
这导致我的测试源文件中的测试代码具有相当仪式性的行:
from cooccurrence.cooccurrence import CoCreate
如果我只需要一个模块,我将如何简化整个设置,相反,我应该采用什么样的项目结构来管理同一包下的多个模块?
为了进行测试,我只需使用 python -m unittest discovery -v
,如果有一个解决方案也可以在 PyCharm 中无缝启用该项目,我们将非常感激。
最佳答案
您可以导入 __init__.py
中的文件,这样它将在包级别可用。例如,您可以在 cooccurrence/__init__.py
中执行以下操作:
from cooccurrence import CoCreate
然后在您的测试文件中:
from cooccurrence import CoCreate
这将是 Pythonic 的方式
关于python 3 项目结构(单机与单机)多个模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48516002/
如何制作 agario 的 java 单人游戏版本?我想使用面向对象编程。所以应该有 Dot、Blob 和一个 Controller Object。(我只是想分享我的代码,所以不要投反对票:) 最佳答
我有一个关于速度和性能的问题在单台机器上使用多个虚拟化节点 VS 在单台机器上使用单节点。 哪一个会表现更好? 之所以问这个问题是因为我目前是在单机上学习hadoop,在网上看到一些教程是单机多虚拟化
语境 我喜欢 Clojure。我喜欢 Clojure 胜过喜欢 ClojureScript。 我喜欢 DOM 胜过喜欢 Swing。 我打算主要在 Clojure 中构建一个 GUI 应用程序,但使用
我们目前正在使用 Opencart - 2.3.x 通过 ELB 为一个 AWS 实例下的多个域提供服务。 我们已经为一个域设置了 HTTPS,但对于其他域,我们不能做同样的事情,因为我们不能创建重复
我是一名优秀的程序员,十分优秀!