Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    pytest-django 2.3.0

    Download button

    No screenshots available
    Downloads: 171  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Andreas Pelme | More programs
    BSD License / FREE
    July 9th, 2012, 10:11 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    pytest-django description

    A Django plugin for py.test

    pytest-django is a py.test plugin that provides a set of useful tools for testing Django applications.

    Changes between orginal and this fork

    The original pytest_django module didn't work for me. It was written for django 1.1 and is probably not completely compatible with django 1.2.1.

    This fork uses django's TestSuite and TestCase to setup the test database and environment instead of implementing the database setup code in the py.test plugin. As a result some command line options have been removed:

    1. --copy_live_db
    2. --database

    Installation

     python setup.py install

    Then simply create a conftest.py file in the root of your Django project containing:

    pytest_plugins = ['django']

    Usage

    Run py.test in the root directory of your Django project:

     py.test

    This will attempt to import the Django settings and run any tests.

    Note that the default py.test collector is used, as well as any file within a tests directory. As such, so it will not honour INSTALLED_APPS. You must use collect_ignore in a conftest.py file to exclude any tests you don't want to be run.

    See py.test's documentation for more information, including usage of the -k option for selecting specific tests.

    A --settings option is provided for explicitly setting a settings module, similar to manage.py.

    pytest_django makes py.test's built in unittest support fully backwards compatible with Django's unittest test cases. If they are failing, this is a bug.

    Hooks

    The session start/finish and setup/teardown hooks act like Django's test management command and unittest test cases. This includes creating the test database and maintaining a constant test environment, amongst other things.

    Funcargs

    client

    A Django test client instance.

    Example:

    def test_something(client):
     assert 'Success!' in client.get('/path/')

    rf

    An instance of Simon Willison's excellent RequestFactory.

    settings

    A Django settings object that restores itself after the tests have run, making it safe to modify for testing purposes.

    Example:

    def test_middleware(settings, client):
     settings.MIDDLEWARE_CLASSES = ('app.middleware.SomeMiddleware',)
     assert 'Middleware works!' in client.get('/')


    Decorators

    @py.test.urls

    Provides the ability to change the URLconf for this test, similar to the urls attribute on Django's TestCase.

    Example:

    @py.test.urls('myapp.test_urls')
    def test_something(client):
     assert 'Success!' in client.get('/some_path/')


    Fixtures

    Fixtures can be loaded with py.test.load_fixture(name). For example:

    def pytest_funcarg__articles(request):
     py.test.load_fixture('test_articles')
     return Article.objects.all()



    Product's homepage

    Requirements:

    · Python
    · py.test
    · Django

      


    TAGS:

    py.test plugin | Django testing | Django | py.test | plugin

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM