Skip to main content

Utilities to test Django applications with nosetests.

Project description

  1. Introduction

  2. Requirements

  3. Installation

  4. Usage

Introduction

tddspry is collection of utilities for testing Django applications with nosetests library.

Requirements

Installation

To install:

python setup.py install

Or via easy_install:

easy_install tddspry

Also you can retrieve fresh version of tddspry from GitHub:

git clone git://github.com/playpauseandstop/tddspry.git

Usage

We create tddspry to easying testing Django projects and applications. Okay, let’s see, to test login and logout pages in your Django project, you need only:

from tddspry.django import HttpTestCase
from tddspry.django.helpers import create_user

from django.conf import settings


class TestLoginPage(HttpTestCase):

    def test_login(self):
        user = create_user('username', 'password')
        self.login('username', 'password')
        self.url(settings.LOGIN_REDIRECT_URL)

    def test_logout(self):
        user = create_user('username', 'password')
        self.login('username', 'password')
        self.logout()
        self.url('/')

That’s all ;) But really for test_login,

  • First, HttpTestCase creates test sqlite3 database in memory and starts Django WSGI-server.

  • Then, we creates test user by create_user helper.

  • Next, twill browser goes to your 'auth_login' page and checks that response code is 200.

  • Next, twill browser fill out login form with USERNAME and PASSWORD values and submits it. Also here twill browser again checks that response code is 200.

  • And finally, we check that current url after success login is our LOGIN_REDIRECT_URL that set in projects settings.

And for test_logout we repeate these steps and adding logging out from current Django session and simple check that after logout we go to index page.

Easy? No? Okay, create new issue on GitHub and say how exactly create easy tests for Django applications :)

ps. More examples how-to usage tddspry exist in tests for testproject project in tddspry repository.

Project details


Download files

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

Source Distribution

tddspry-0.2.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file tddspry-0.2.tar.gz.

File metadata

  • Download URL: tddspry-0.2.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tddspry-0.2.tar.gz
Algorithm Hash digest
SHA256 f7e03a8c9bbd4dc67f0331ab0dc0e37831c5f3a37012b136ca99333d0d5c1ace
MD5 7fe14beedc3c3453e000ebb3093d8b32
BLAKE2b-256 0f33dc3b1b037e6851e4187f9b05ee8cba23bf00b1524f2132823deda1f3ba76

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page