【发布时间】:2021-03-23 22:52:43
【问题描述】:
当我尝试在 pycharm 中进行简单的单元测试时,它不起作用,输出是“在 0.000 秒内运行 0 次测试”,而当我在 Geany 中做完全相同的事情时,它会运行,“运行 1 次测试0.000 秒”有人能找出原因吗?
import unittest
class Test(unittest.TestCase):
def test_cos_tam(self):
r = '200'
self.assertEqual(r, '200')
unittest.main()
C:\Users\wycze\Desktop\python_work\WizualizacjaDanych\Scripts\python.exe "D:\pycharm\PyCharm Community Edition 2020.3.2\plugins\python-ce\helpers\pycharm\_jb_unittest_runner.py" --path C:/Users/wycze/Desktop/python_work/WizualizacjaDanych/test_python_repos.py
Testing started at 23:45 ...
----------------------------------------------------------------------
Launching unittests with arguments python -m unittest C:/Users/wycze/Desktop/python_work/WizualizacjaDanych/test_python_repos.py in C:\Users\wycze\Desktop\python_work\WizualizacjaDanych
Ran 0 tests in 0.000s
OK
Process finished with exit code 0
Empty suite
Empty suite
【问题讨论】:
-
我的猜测是 Pycharm 的配置方式有问题。由于您没有向我们展示配置,因此很难告诉您更多信息。也就是说,您可能想尝试使用superuser.com,因为这不是关于您的代码的问题,而是关于您正在使用的程序(IDE)的问题。
-
@KarlKnechtel 哦,你可能是对的,我不知道这个网站。感谢您的回答
-
直奔
python -m unittest path/to/file/test_python_repos.py有效吗? -
我认为这与指定文件名与指定模块或类名有关。
标签: python unit-testing pycharm geany