问题
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