Home

Awesome

django-test-client-extensions

Extensions to Django's built-in test client.

Features

Examples

Setup

Define a base test case for your tests:

from django import test import TestCase as BaseTestCase

import testclient_extensions


class TestCase(test.TestCase):
    client_class = testclient_extensions.Client

or use a pytest fixture:

@pytest.fixture
def client():
    from testclient_extensions import Client
    return Client()

client.login

# ...
user = my_factories.create_user()
self.client.login(user)
# ...

client.json

Automatically encode json-data and set the proper content-type.

# ...
data = {"complex": ["piece", "of", "data"]}
response = self.client.json.post(url, data)
# ...

Installation

pip install django-restclient-extensions