Python单元测试根本没有运行

编程入门 行业动态 更新时间:2024-10-12 03:20:54
本文介绍了Python单元测试根本没有运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是第一次尝试参考

我在这里想念什么?

更新

添加更多详细信息:

我的项目:

PyDev软件包浏览器

解决方案

问题是您可能尚未配置项目中的哪个路径应位于 PYTHONPATH 中.

用PyDev来说,这是项目的源文件夹.

您应该能够右键单击一个文件夹,然后选择 PyDev>设置为源文件夹(添加到PYTHONPATH),以将该文件夹添加到 PYTHONPATH .

在以下位置有更好的描述: www.pydev/manual_101_project_conf2.html

此外,请确保您阅读入门指南: www.pydev/manual_101_root.html

如果仍然无法正常运行,请发布 PyDev软件包资源管理器的屏幕截图.

I am first time trying out python unit tests referring to this article. I have PyDev plugin installed in my Eclipse.

My test_hello.py looks like this:

import unittest class TestHello(unittest.TestCase): def test_abc(self): print("Test!!!") result = True self.assertEqual(result, True, "ohno")

When I Right click on source > Run As > Python unit-test, it outputs:

Finding files... done. Importing test modules ... PYTHONPATH not found for file: D:\workspaces\python-ws\test\test_h done. ---------------------------------------------------------------------- Ran 0 tests in 0.000s OK

Also in PyUnit tab, it doesnt show anything:

What I am missing here?

Update

Adding more details:

My project:

PyDev package explorer

解决方案

The issue is that you have probably not configured which path in your project should be in the PYTHONPATH.

In PyDev terms, this is the source folder for a project.

You should be able to right-click a folder and select PyDev > Set as Source Folder (add to PYTHONPATH) to add that folder to the PYTHONPATH.

There's a better description at: www.pydev/manual_101_project_conf2.html

Also, make sure that you take a look at the getting started guide: www.pydev/manual_101_root.html

If you still can't have it working, please post a screenshot of your PyDev Package Explorer.

更多推荐

Python单元测试根本没有运行

本文发布于:2023-11-24 02:26:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623631.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!