Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

tddspry

Utilities to test Django applications with nosetests and twill.

TestCases

NoseTestCase

Base TestCase in tddspry. The main advantages with standart Python's unittest.TestCase are that it depends object and all functions from nose.tools existed as NoseTestCase's methods.

tddspry.django

TestCases

tddspry.django serves several custom TestCase's for test your Django's applications.

DatabaseTestCase

Depends on NoseTestCase. On setup DatabaseTestCase creates test sqlite3 database in :memory: and on teardown removes it.

Custom methods
  • check_create(model, **kwargs)
  • check_delete(instance)
  • check_update(instance, **kwargs)

HttpTestCase

Depends on NoseTestCase. On setup HttpTestCase creates test database via django.test.create_test_db and on teardown removes it.

Also this TestCase consists of all twill functions as class methods.

Custom methods
  • find(what, flags='', flat=False)

    Use flat=True to disable regexp matching and use raw what in html expression.

More custom helpers for http tests you can find in Helpers section.

Helpers

Also tddspry.django gives several custom helpers to easying your http tests. To import it use:

from tddspry.django.helpers import *

List of helpers:

  • go200(url)
  • login(USERNAME, PASSWORD, login_url=settings.LOGIN_URL, form_id=1)
  • login_to_admin(USERNAME, PASSWORD)
  • logout(logout_url=settings.LOGOUT_URL)
  • submit200()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment