python310Packages.django_4: enable tests on linux

Tests still fail on darwin because of missing timezone information, no
idea how to resolve that. TZDIR does work on Linux.
This commit is contained in:
Martin Weinelt 2022-06-10 23:07:30 +02:00
parent 4a269e1afa
commit 7109d10aab
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
2 changed files with 77 additions and 9 deletions

View File

@ -26,15 +26,14 @@
, docutils
, geoip2
, jinja2
, python-memcached
, numpy
, pillow
, pylibmc
, pymemcache
, python
, pytz
, pywatchman
, pyyaml
, pytz
, redis
, selenium
, tblib
@ -58,6 +57,9 @@ buildPythonPackage rec {
src = ./django_4_set_zoneinfo_dir.patch;
zoneinfo = tzdata + "/share/zoneinfo";
})
# make sure the tests don't remove packages from our pythonpath
# and disable failing tests
./django_4_tests.patch
] ++ lib.optionals withGdal [
(substituteAll {
src = ./django_4_set_geos_gdal_lib.patch;
@ -67,6 +69,11 @@ buildPythonPackage rec {
})
];
postPatch = ''
substituteInPlace tests/utils_tests/test_autoreload.py \
--replace "/usr/bin/python" "${python.interpreter}"
'';
nativeBuildInputs = [
setuptools
];
@ -85,37 +92,47 @@ buildPythonPackage rec {
];
};
# Fails to import asgiref in ~200 tests
# ModuleNotFoundError: No module named 'asgiref'
doCheck = false;
nativeCheckInputs = [
# tests/requirements/py3.txt
aiosmtpd
docutils
geoip2
jinja2
python-memcached
numpy
pillow
pylibmc
pymemcache
pytz
pywatchman
pyyaml
pytz
redis
selenium
tblib
tzdata
] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
doCheck = !stdenv.isDarwin;
preCheck = ''
# make sure the installed library gets imported
rm -rf django
# provide timezone data, works only on linux
export TZDIR=${tzdata}/${python.sitePackages}/tzdata/zoneinfo
'';
checkPhase = ''
runHook preCheck
${python.interpreter} tests/runtests.py
pushd tests
${python.interpreter} runtests.py --settings=test_sqlite
popd
runHook postCheck
'';
__darwinAllowLocalNetworking = true;
meta = with lib; {
changelog = "https://docs.djangoproject.com/en/${lib.versions.majorMinor version}/releases/${version}/";
description = "A high-level Python Web framework that encourages rapid development and clean, pragmatic design.";

View File

@ -0,0 +1,51 @@
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 6d67c2931a..0c1f407f88 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -127,6 +127,7 @@ class AdminScriptTestCase(SimpleTestCase):
del test_environ["DJANGO_SETTINGS_MODULE"]
python_path = [base_dir, django_dir, tests_dir]
python_path.extend(ext_backend_base_dirs)
+ python_path.extend(sys.path)
test_environ["PYTHONPATH"] = os.pathsep.join(python_path)
test_environ["PYTHONWARNINGS"] = ""
diff --git a/tests/auth_tests/test_hashers.py b/tests/auth_tests/test_hashers.py
index 36f22d5f09..6cc6888980 100644
--- a/tests/auth_tests/test_hashers.py
+++ b/tests/auth_tests/test_hashers.py
@@ -1,4 +1,4 @@
-from unittest import mock, skipUnless
+from unittest import mock, skipUnless, skip
from django.conf.global_settings import PASSWORD_HASHERS
from django.contrib.auth.hashers import (
@@ -241,6 +241,7 @@ class TestUtilsHashPass(SimpleTestCase):
@ignore_warnings(category=RemovedInDjango50Warning)
@skipUnless(crypt, "no crypt module to generate password.")
+ @skip("Legacy crypt algorithms are unsupported in nixpkgs")
@override_settings(
PASSWORD_HASHERS=["django.contrib.auth.hashers.CryptPasswordHasher"]
)
diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py
index 62cbffbee9..2f0ec718f8 100644
--- a/tests/settings_tests/tests.py
+++ b/tests/settings_tests/tests.py
@@ -2,7 +2,7 @@ import os
import sys
import unittest
from types import ModuleType, SimpleNamespace
-from unittest import mock
+from unittest import mock, skip
from django.conf import (
ENVIRONMENT_VARIABLE,
@@ -342,6 +342,7 @@ class SettingsTests(SimpleTestCase):
getattr(s, "foo")
@requires_tz_support
+ @skip("Assertion fails, exception does not get raised")
@mock.patch("django.conf.global_settings.TIME_ZONE", "test")
def test_incorrect_timezone(self):
with self.assertRaisesMessage(ValueError, "Incorrect timezone setting: test"):