我unittest用来测试我的 Flask 应用程序,并nose实际运行测试。
我的第一组测试是确保测试环境干净,并防止在 Flask 应用程序配置的数据库上运行测试。我确信我已经干净地设置了测试环境,但我希望在不运行所有测试的情况下对此有所保证。
import unittest
class MyTestCase(unittest.TestCase):
def setUp(self):
# set some stuff up
pass
def tearDown(self):
# do the teardown
pass
class TestEnvironmentTest(MyTestCase):
def test_environment_is_clean(self):
# A failing test
assert 0 == 1
class SomeOtherTest(MyTestCase):
def test_foo(self):
# A passing test
assert 1 == 1
如果它失败,我想TestEnvironmentTest引起unittest或nose保释,并阻止SomeOtherTest和任何进一步的测试运行。是否有一些内置的方法可以这样做unittest(首选)或nose允许这样做?