From d22e794c37a5c85f361a056806f1aa10fa2587b4 Mon Sep 17 00:00:00 2001 From: eddy BOUR Date: Sun, 9 Oct 2016 10:27:12 +0200 Subject: [PATCH] fix tests & support django 1.10.1+ --- .gitignore | 3 ++ django_qunit/templates/qunit/index.html | 61 ++++++++++++------------- django_qunit/urls.py | 25 +++++----- django_qunit/views.py | 6 +-- example/manage.py | 9 ++++ example/runserver.sh | 2 +- example/settings.py | 4 +- example/urls.py | 6 +-- 8 files changed, 63 insertions(+), 53 deletions(-) create mode 100644 .gitignore create mode 100644 example/manage.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78eb914 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/* +build/* +**.pyc \ No newline at end of file diff --git a/django_qunit/templates/qunit/index.html b/django_qunit/templates/qunit/index.html index 4607b37..56ece0d 100644 --- a/django_qunit/templates/qunit/index.html +++ b/django_qunit/templates/qunit/index.html @@ -1,35 +1,34 @@ - - QUnit Test Suite - - - {% for url in suite.extra_urls %} - - {% endfor %} - {% for url in suite.extra_media_urls %} - - {% endfor %} - {% for file in files %} - - {% endfor %} - - -

QUnit Test Suite ({{ suite.name|capfirst }})

-

-
- {% if in_directory or subsuites %} - - {% endif %} -

-
    - +

    +
      + diff --git a/django_qunit/urls.py b/django_qunit/urls.py index 63ca7f0..daa35b9 100644 --- a/django_qunit/urls.py +++ b/django_qunit/urls.py @@ -1,19 +1,16 @@ -from django.conf.urls.defaults import * +from django.conf.urls import * from django.conf import settings + +from django.views.static import serve +from django_qunit import views + import os media_root = os.path.join(os.path.dirname(__file__), 'media') -urlpatterns = patterns('', - url(r'^tests/(?P.*)$', 'django.views.static.serve', { - 'document_root': settings.QUNIT_TEST_DIRECTORY, - }, name='qunit_test'), - url(r'^qunit/qunit.js', 'django.views.static.serve', { - 'document_root': media_root, 'path': 'qunit/qunit.js', - }, name='qunit_js'), - url(r'^qunit/qunit.css', 'django.views.static.serve', { - 'document_root': media_root, 'path': 'qunit/qunit.css', - }, name='qunit_css'), - url('^(?P.*)$', 'django_qunit.views.run_tests', - name='qunit_test_overview'), -) +urlpatterns = [ + url(r'^tests/(?P.*)$', serve, { 'document_root': settings.QUNIT_TEST_DIRECTORY, }, name='qunit_test'), + url(r'^qunit/qunit.js', serve, { 'document_root': media_root, 'path': 'qunit/qunit.js', }, name='qunit_js'), + url(r'^qunit/qunit.css', serve, { 'document_root': media_root, 'path': 'qunit/qunit.css',}, name='qunit_css'), + url('^(?P.*)$', views.run_tests, name='qunit_test_overview'), +] diff --git a/django_qunit/views.py b/django_qunit/views.py index d19893f..7501205 100644 --- a/django_qunit/views.py +++ b/django_qunit/views.py @@ -1,6 +1,6 @@ from django.shortcuts import render_to_response from django.conf import settings -from django.utils import simplejson +import json import os @@ -24,8 +24,8 @@ def get_suite_context(request, path): # load suite.json if present if 'suite.json' in files: file = open(os.path.join(full_path, 'suite.json'), 'r') - json = file.read() - suite.update(simplejson.loads(json)) + suite_json = file.read() + suite.update(json.loads(suite_json)) previous_directory = parent_directory(path) diff --git a/example/manage.py b/example/manage.py new file mode 100644 index 0000000..d4be4c3 --- /dev/null +++ b/example/manage.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/example/runserver.sh b/example/runserver.sh index cec1814..7182094 100755 --- a/example/runserver.sh +++ b/example/runserver.sh @@ -1,4 +1,4 @@ #!/bin/sh PYTHONPATH=`pwd`:`pwd`/..:$PYTHONPATH -django-admin.py runserver --settings=settings 8080 +python manage.py runserver --settings=settings 8080 diff --git a/example/settings.py b/example/settings.py index cbf9da1..bf152d8 100644 --- a/example/settings.py +++ b/example/settings.py @@ -7,8 +7,10 @@ DEBUG = True TEMPLATE_DEBUG = DEBUG -ROOT_URLCONF = 'example.urls' +ROOT_URLCONF = 'urls' INSTALLED_APPS = ( 'django_qunit', ) + +SECRET_KEY = 'foo' \ No newline at end of file diff --git a/example/urls.py b/example/urls.py index 9974fe8..6ae2a2f 100644 --- a/example/urls.py +++ b/example/urls.py @@ -1,5 +1,5 @@ -from django.conf.urls.defaults import * +from django.conf.urls import * -urlpatterns = patterns('', +urlpatterns = [ url('^qunit/', include('django_qunit.urls')) -) +]