下面的测试、代码和结果都有问题。
我试图从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
>>> 发布于 2020-06-08 10:01:07
这看起来像是PythonAnywhere中IDE中的一个bug --最简单的解决方法是关闭编辑器中的控制台(使用exit()),然后刷新页面,然后使用"Bash here“按钮启动一个新控制台,该按钮将出现在旧控制台所在的位置。然后,您可以使用@jfaccioni在对您的问题的注释中建议的命令:
python3 -m unittest code.py...but将测试结果与编辑器放在同一个浏览器选项卡上。
https://stackoverflow.com/questions/62172925
复制相似问题