Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 单元测试不起作用_Python 3.x_Unit Testing_Selenium - Fatal编程技术网

Python 3.x 单元测试不起作用

Python 3.x 单元测试不起作用,python-3.x,unit-testing,selenium,Python 3.x,Unit Testing,Selenium,我试图通过使用python3 functional_tests.py——文件名——来运行单元测试,但我得到了 "---------------------------------------------------------------------- 在0.000秒内运行了0个测试 好的” 这是我的密码: 从selenium导入webdriver 导入单元测试 class NewVisitorTest(unittest.TestCase): def setUp(self):

我试图通过使用
python3 functional_tests.py
——文件名——来运行单元测试,但我得到了

"----------------------------------------------------------------------

在0.000秒内运行了0个测试

好的”

这是我的密码: 从selenium导入webdriver 导入单元测试

class NewVisitorTest(unittest.TestCase):
    def setUp(self):
        self.browser = webdriver.Firefox()

    def tearDown(self):
        self.browser.quit()

    def testcan_start_a_list_and_retrieve_it_later(self):
        self.browser.get('http://localhost:8000')
        self.assertIn('To-Do', self.browser.title)
        self.fail('finish test')
    if __name__ == '__main__':
        unittest.main(warnings='ignore')

我正在使用python 3.5.2

您是否正在使用python进行测试驱动开发的练习?这些是Django测试吗?如果它们是Django测试,您可以尝试以下操作:

python3 manage.py test functional_tests

即使如此,评论者仍然正确地指出,
如果uu name
。。。代码的一部分不应缩进。它应该完全在左边空白处。

该代码应该有效。你是如何执行的?请使用您使用的完整命令更新您的问题。完成。。我使用
python3 functional\u tests.py
Your
if\uuu name\uuu='\uu main\uuu'
块缩进,使其成为类的一部分-它将永远不会被执行。我认为测试类是不可发现的,要么jasonharper回答,要么尝试将类名更改为
TestNewVisitor(UnitTestTest.TestCase)