Skip to main content

Utilites for Django tests.

Project description

Django Test Helper

Django Test Helper provides some utility functions when testing Django applications


Run `pip install django-test-helper`


A context that provides a Django test Client instance with an authenticated user. It takes a username and a password as arguments.

from django.test import TestCase
from test_helper.utils import authenticated_user
from django.core.urlresolvers import reverse

class MyTest(TestCase):
def test_protected_view(self):
with autenticated_user('username', 'pass') as client:
response = client.get(reverse('protected_view')
self.assertEqual(response.status, 200)

Creates on-the-fly an image and returns it. It takes a size tuple and a color rgb tuple.

from django.test import TestCase
from test_helper.utils import image_file

class MyTest(TestCase):
def test_form(self):
data = {
'first_name': 'John',
'last_name': 'Smith',
image = image_file(size=(100, 100),
color=(128, 128, 128))
files = {
'avatar': image,
form = ProfileForm(data, files)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-test-helper, version 0.1a2
Filename, size File type Python version Upload date Hashes
Filename, size (6.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page