django-test-helper

Utilites for Django tests.


License
Other
Install
pip install django-test-helper==0.1a2

Documentation

Django Test Helper

Django Test Helper provides some utility functions when testing Django applications

Installation

Run pip install django-test-helper

Helpers

authenticated_client

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

```python from django.test import TestCase from testhelper.utils import authenticateduser from django.core.urlresolvers import reverse

class MyTest(TestCase): def testprotectedview(self): with autenticateduser('username', 'pass') as client: response = client.get(reverse('protectedview') self.assertEqual(response.status, 200) ```

image_file

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

```python from django.test import TestCase from testhelper.utils import imagefile

class MyTest(TestCase): def testform(self): data = { 'firstname': 'John', 'lastname': 'Smith', } image = imagefile(size=(100, 100), color=(128, 128, 128)) files = { 'avatar': image, } form = ProfileForm(data, files) self.assertTrue(form.is_valid()) ```