只有前一个测试成功,Unittest才会运行测试

时间:2015-05-25 16:03:03

标签: python unit-testing flask

我正在为我的CRUD烧瓶应用https://github.com/Leo-g/Flask-Skeleton/blob/master/tests.py

编写测试用例

我想确保只有在添加测试成功时才运行更新和删除测试。

def test_add(self):
            rv = self.app.post('/users/add', data=dict(name = 'test name', email = 'test@email.com'), follow_redirects=True)

            assert 'Add was successful' in rv.data.decode('utf-8')


def test_Update(self):

             with app.app_context():
                id = Users.query.first().id
                rv = self.app.post('/users/update/{}'.format(id), data=dict(name = 'test name update', email = 'test@email.update'), follow_redirects=True)
                assert 'Update was successful' in rv.data.decode('utf-8')

在阅读文档时,我看到这可以通过unittest.skip装饰器完成,但我不确定如何实现它。

1 个答案:

答案 0 :(得分:0)

运行测试时,可以使用--failfast命令行选项,以便在单个测试失败后停止测试套件。例如,如果您通常使用命令python -m unittest运行测试,则可以将其更改为python -m unittest --failfast

相关问题