在单元测试期间启动Django应用程序

我目前正在使用python 2.7,django 1.6.5并在API文件上运行单元测试。

下面是我要从中运行所有单元测试文件的文件

Integration.py

loader= unittest.TestLoader()
start_dir='tp/pyfiles'
suite=loader.discover(start_dir)
runner = unittest.TextTestRunner()
runner.run(suite)

下面是我为API测试编写的代码的一部分

test_file1.py

class api_test(unittesting.TestCase):
    def setUp(self):
        print "SetUp Function called"
        command = 'gnome -terminal -e \'python manage.py runserver ' + 1585 + '\''
        try:
            os.system(command)
            print "SetUp Done"
        except Exception as e:
            print e

除了上述命令之外,还有其他方法可以启动服务器吗?

此外,运行Integration.py的正确方法是什么?

1.python -m unittest integration
or 
2.python integration.py

如果我和第一个一起跑步,我会得到

Ran 4 Tests

OK

Ran 0 Tests

Ok

其他

Ran 4 Tests

OK

请提出建议

einspei 回答:在单元测试期间启动Django应用程序

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3164279.html

大家都在问