lundi 25 mai 2015

Unittest run a test only if the previous one is a success

I am writing test cases for my CRUD flask app http://ift.tt/1HslzvD

I want to ensure that the update and delete tests run only if the add tests succeeds.

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')

While reading the docs I see that this can be done via the unittest.skip decorator but I am not sure How I can implement it.

Aucun commentaire:

Enregistrer un commentaire