Python与Teamcity的单位测试

发布于 2025-01-26 12:54:05 字数 563 浏览 2 评论 0原文

我喜欢在Teamcity Build期间进行单位测试。我在构建中配置了此步骤,就像pytest一样,使用参数测试/单位/*。py。在此运行期间,我对我实际测试的模块有“ ModulenotFoundError”。因此,我的猜测是树结构或工作目录正在改变。 因此,我的工作树看起来像这样:

pipeline ---> __init__.py (empty file)
pipiline ---> model.py 

在此文件内部,我有此定义

 class Model():

夹以下内容:

test ---> unit ---> test_model.py

内部test_model。

from model import Model

test

ModuleNotFoundError: No module named 'model'

文件 如何在Python中做到这一点。

I like to run unit-tests during Teamcity build. I configure this step in the build like pytest with arguments test/unit/*.py. During this run I have "ModuleNotFoundError" for a module that I am actually testing. So my guess is that somehow the tree structure or working directory is changing.
So my working tree looks like that:

pipeline ---> __init__.py (empty file)
pipiline ---> model.py 

inside this file I have this definition

 class Model():

The test folders are following:

test ---> unit ---> test_model.py

inside test_model.py I have:

from model import Model

During the run I have

ModuleNotFoundError: No module named 'model'

I guess I should somehow define the Model class like dll, but I do not understand how to do this in Python.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文