Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Better transaction management in Django TestCase.

Compare
Choose a tag to compare
@Pastromhaug Pastromhaug released this 27 Sep 18:29
· 91 commits to master since this release
454c949

Atomiq publish will throw an exception if not used within a transaction, and we want to make sure nobody ships code that is going to throw this exception in production. The problem is that Django TestCase wraps all test functions in a transaction, which masks this error.

This release makes a few changes to the transaction checking:

  1. If we are in a TestCase unit test function, we expect to find 3 transactions total: two created by Django and one by the user.

  2. If we are in the TestCase setUpClass function, we expect to find 2 transactions: one created by Django and by the user.