Python unitest不会从PythonAnywhere运行测试功能

问题描述 投票:0回答:1

我在下面的单元测试测试,代码和结果方面遇到问题。

我尝试从PythonAnywhere IDE运行测试,并说已经完成了0测试。

我通过打印测试了代码,以找出问题出在哪里,并且我发现解释器甚至没有进入该功能来查看测试。我知道测试名称应以“ test_”开头。还有其他想法吗?

如果有问题,我正在研究pythonAnywhere。

我的代码:

import unittest
import signUpForm

class Test_signUp(unittest.TestCase):

    print ("i got to here")
    def test_Utility(self):
        print ("but never here")
        # test all utlity functions in the sign up form. and delete the changes afterward
        #check system addition and manipulation
        self.assertEqual(addSystem ("dungeons" , 8000) , "added dungeons to systems list")

if __name__ == '__main__':
    unittest.main(exit = False)

当我运行它时,我得到:

i got to here
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
>>> 
python unit-testing python-unittest pythonanywhere
1个回答
0
投票

这看起来像PythonAnywhere中的IDE中的错误-最简单的解决方法是在编辑器中关闭控制台(使用exit()),然后刷新页面,然后使用“此处的Bash控制台”启动新控制台。按钮,它将显示在旧控制台所在的位置。然后,您可以使用@jfaccioni在对问题的注释中建议的命令:

python3 -m unittest code.py

...但是测试结果与编辑器位于同一浏览器选项卡上。

© www.soinside.com 2019 - 2024. All rights reserved.