1. Jason Moiron
  2. johnny-cache
  3. Issues
Issue #25 open

Running Django's tests with johnny-cached enabled

Alexis Petrounias
created an issue

When in test mode, Django temporarily re-assigns the various transaction methods (//commit//, //rollback//, and so on) to dummy methods, but keeps a copy of the normal methods with the name //real_// prefixed.

To get the tests and johnny-cache playing together, you can check for the above re-assignment by doing the following in the //patch// method of the //TransactionManager//:

{{{ from django.test import testcases

if django_transaction.commit.code == testcases.nop.code:



and then patching as so:

{{{ self._originals['rollback'] = \ testcases.real_rollback

testcases.real_rollback = self._patched( testcases.real_rollback, False) }}}

and so on.

Comments (6)

  1. Alexis Petrounias reporter
    • changed status to open

    Unfortunately it appears this does not resolve the issue, because it is possible for certain test cases to manually reinstate Django's normal transactions (because the test cases need to test transaction-dependent behavior). To fix this a custom test runner would need to patch the transaction methods from django.test.testcases explicitly, instead of relying on the name of the method in django.db.transaction.

  2. Log in to comment