This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Integrate QUnit JavaScript tests into a Django test suite via nose.

Installation

  1. pip install django-nose-qunit.

  2. Add 'django_nose_qunit' to your INSTALLED_APPS setting.

  3. Ensure that you’re using nose as your test runner by using the following Django setting

    TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
    
  4. Enable the nose plugin by adding it to the NOSE_PLUGINS Django setting:

    NOSE_PLUGINS = [
        'django_nose_qunit.QUnitPlugin'
    ]
    

    and the NOSE_ARGS Django setting:

    NOSE_ARGS = [
        '--with-django-qunit',
    ]
    
  5. Add an entry to your URL configuration:

    from django_nose_qunit.urls import urlpatterns as qunit_urlpatterns
    urlpatterns += qunit_urlpatterns
    

    This adds new URLs of the form /qunit/*, and they return a 404 unless DEBUG is True or QUnit tests have been initialized as part of a test run.

  6. Configure Selenium as explained in the sbo-selenium README.

  7. Make sure MEDIA_URL is set to some non-empty string, like “/media/”. If this is not done, the live test server can occasionally get confused and treat requests for a test page as requests for static files.

Creating Unit Tests

Tests can be written in JavaScript using QUnit as normal; see the QUnit documentation for details. You need only create a JavaScript file, not the HTML page that will load it (that is provided by the template at qunit/template.html). If your tests depend on HTML fixtures in the qunit-fixture div, create those as HTML fragments in files which can be loaded as templates. External script dependencies should be files in the staticfiles load path. You should add QUnit.Django.start(); before your test definitions and QUnit.Django.end(); at the end of your test definitions; this allows the tests to start executing at an appropriate time depending on whether they’re running in a browser, in a nose test run, or inside a require() block of an AMD loader like RequireJS.

To make nose aware of your QUnit tests, create a subclass of django_nose_qunit.QUnitTestCase in a file which would normally be searched by nose, for example my_app/test/qunit/test_case.py. It can contain as little as just the test_file attribute (a path to a QUnit test script, relative to STATIC_URL). Any script dependencies for your test script should be given as paths relative to STATIC_URL in the dependencies attribute. Paths to HTML fixture templates are listed in the html_fixtures attribute.

Running Unit Tests

Use your normal test execution command (using django-admin.py or manage.py). Execution can be restricted to one or more specified packages and/or classes as normal (“myapp”, “myapp.tests.qunit”, “myapp.tests.qunit:MyTestCase”, etc.). There is currently no support for running only a single module or test within a QUnit test script; QUnit module and test names can be arbitrary strings, which makes it difficult for the nose command line parser to handle them.

To run the QUnit tests in a regular web browser, use the runserver management command with QUNIT_DYNAMIC_REGISTRY set to True (by default, it has the same value as DEBUG). If DEBUG is False, you’ll also need to use the --insecure parameter to serve static files. You can then access a list of links to the available QUnit tests at a URL like http://localhost:8000/qunit/. This can be useful when first developing a test script and when troubleshooting failing tests.

How It Works

QUnitTestCase is a subclass of Django’s LiveServerTestCase, which starts a Django test server in the background on setup of the test class and stops it on teardown. django_nose_qunit includes a nose plugin which can accommodate tests written as simple wrappers for JavaScript test files. When nose searches for tests to run, the plugin tells it how to ask a browser via Selenium WebDriver to load each test script (without running the tests) in order to get information about the modules and tests it contains. Once these tests are enumerated, they are run like any other test case. The first execution of a test from a QUnit test script runs all of the tests in the script, and the results are stored. Each test case then reports success or failure based on the reported results, with failures including any messages provided by QUnit.

Release History

Release History

1.6.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.6.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.5.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.5.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.5.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.5.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.4.10

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.4.9

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_nose_qunit-1.6.1-py2.py3-none-any.whl (49.9 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel May 5, 2016
django-nose-qunit-1.6.1.tar.gz (44.4 kB) Copy SHA256 Checksum SHA256 Source May 5, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting