Golden Codes - armanexplorer planet

Practical code snippets for Django, Python, Bash, Git and All!

View on GitHub

Docs

asserts

check exception raises

TransactionTestCase

Note that we have to use TransactionTestCase and not TestCase. TestCase wraps every test inside a transaction block which gets rolled back at the end of the test. This is not suitable for our tests, which rely on having control over the outer transaction block. TransactionTestCase doesn’t wrap anything in a transaction, so our code can actually make changes to the test database.