mercredi 28 novembre 2018

Django tests display traceback of expected exception in assertRaises

I'm testing a django view with APIClient. One of the test cases checks whether an exception is raised:

    self.assertRaises(
        IntegrityError,
        self.client.post,
        path='/some/url/to/view/',
        data={
            'test': 'data'
        },
        format='json'
    )

Although the test passes, the client call raises the expected exception with printing the full traceback. Can I somehow change this behaviour? I don't want to see numbers of tracebacks in my test run as this is a common test case.

Aucun commentaire:

Enregistrer un commentaire