1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 11:19:50 +03:00
aports/testing/py3-django-js-asset/Adapt-the-test-suite-to-changes-in-Django.patch
2021-04-05 18:19:18 +00:00

88 lines
2.6 KiB
Diff

From 232536ba50a2e1a0cffc6046dbcdfdec22cb0d9e Mon Sep 17 00:00:00 2001
From: Matthias Kestenholz <mk@feinheit.ch>
Date: Fri, 15 May 2020 08:51:33 +0200
Subject: [PATCH] Adapt the test suite to changes in Django
---
tests/testapp/test_js_asset.py | 16 ++++++++++++----
tox.ini | 14 ++++++++++++++
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/tests/testapp/test_js_asset.py b/tests/testapp/test_js_asset.py
index 902e2a1..3762da6 100644
--- a/tests/testapp/test_js_asset.py
+++ b/tests/testapp/test_js_asset.py
@@ -1,11 +1,15 @@
from __future__ import unicode_literals
+import django
from django.forms import Media
from django.test import TestCase
from js_asset.js import JS
+JS_TYPE = ' type="text/javascript"' if django.VERSION < (3, 1) else ""
+
+
class AssetTest(TestCase):
def test_asset(self):
media = Media(
@@ -25,15 +29,17 @@ def test_asset(self):
html,
)
self.assertInHTML(
- '<script type="text/javascript" src="/static/app/test.js"></script>', # noqa
+ '<script{} src="/static/app/test.js"></script>'.format(JS_TYPE), # noqa
html,
)
self.assertInHTML(
- '<script type="text/javascript" src="/static/app/asset.js" data-the-answer="42" id="asset-script"></script>', # noqa
+ '<script{} src="/static/app/asset.js" data-the-answer="42" id="asset-script"></script>'.format( # noqa
+ JS_TYPE
+ ),
html,
)
self.assertInHTML(
- '<script type="text/javascript" src="/static/app/asset-without.js"></script>', # noqa
+ '<script{} src="/static/app/asset-without.js"></script>'.format(JS_TYPE),
html,
)
@@ -42,7 +48,9 @@ def test_absolute(self):
html = "%s" % media
self.assertInHTML(
- '<script type="text/javascript" src="https://cdn.example.org/script.js"></script>', # noqa
+ '<script{} src="https://cdn.example.org/script.js"></script>'.format(
+ JS_TYPE
+ ),
html,
)
diff --git a/tox.ini b/tox.ini
index 3ddafc6..5ee9d33 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,3 +1,6 @@
+[tox]
+envlist = style,tests,tests-old,tests-master
+
[testenv]
basepython = python3
@@ -37,3 +40,14 @@ changedir = {toxinidir}
skip_install = true
commands =
python tests/manage.py test -v 2 testapp
+
+
+[testenv:tests-master]
+deps =
+ https://github.com/django/django/archive/master.zip
+ coverage
+changedir = {toxinidir}
+skip_install = true
+commands =
+ coverage run tests/manage.py test -v 2 testapp
+ coverage html