Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Carl Meyer March 09, 2012
file 26 lines (16 sloc) 0.592 kb

<!SLIDE incremental>

Imposing no-DB discipline.

  • For certain test cases.

<!SLIDE>

@@@ python
from django.utils.unittest import TestCase

import mock

cursor_wrapper = mock.Mock()
cursor_wrapper.side_effect = \
    RuntimeError("No touching the database!")


@mock.patch(
    "django.db.backends.util.CursorWrapper",
    cursor_wrapper)
class NoDBTestCase(TestCase):
    """Will blow up if you database."""

.notes django.utils.unittest.TestCase vs django.test.TestCase. Latter's assertions mostly useful with the DB, but either way works.

Something went wrong with that request. Please try again.