本文介绍了Python单元测试根本没有运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是第一次尝试参考

我在这里想念什么?

更新

添加更多详细信息:

我的项目:

PyDev软件包浏览器

解决方案

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

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

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

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

此外,请确保您阅读入门指南: http://www.pydev.org/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: http://www.pydev.org/manual_101_project_conf2.html

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

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

这篇关于Python单元测试根本没有运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 21:00