Not Logged In

django-attest 0.7.1

django-attest

Django testing for Attest. Requires Django >=1.2.

Installation

Use pip:

pip install django-attest

Usage

Create a test collection and optionally include one of django-attest’s test
contexts. The result is that a client argument is passed to each test
within the collection. client is a django.test.TestClient object and
allows you to make HTTP requests to your project.

from attest import Tests
from django_attest import TestContext
tests = Tests()
tests.context(TestContext())
@tests.test
def can_add(client):
client.get('/some-url/') # same as self.client.get() if you were using
# the standard django.test.TestCase approach

When using a django.test.TestCase subclass, you’re able to specify various
options that affect the environment in which your tests are executed.
django-attest provides the same functionality via keyword arguments to the
TestContext. The following keyword arguments are supported:

setup.py

Running the tests

python setup.py test

Testing non-reusable apps in a Django project

To test non-reusable apps in a Django project, the app must contain either a
tests or models module with either a suite function that returns a
unittest.TestCase, or simply contains TestCase classes. (see Django’s
documentation
for details).

assert hook

Prior to Attest 0.5, the assert hook was enabled on first import of attest.
As of Attest 0.6, this is no longer the case – instead it occurs when you use
the attest command line program to execute tests.

Since Django uses manage.py as its entry point, django-attest enables the
assert hook automatically when it’s first imported.