Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!


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)

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.