Python unit tests are not running at all

余生长醉 提交于 2019-12-24 12:14:59

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/52593584/python-unit-tests-are-not-running-at-all

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!