summaryrefslogtreecommitdiff
path: root/gnu/packages/django.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/django.scm')
-rw-r--r--gnu/packages/django.scm88
1 files changed, 27 insertions, 61 deletions
diff --git a/gnu/packages/django.scm b/gnu/packages/django.scm
index f8aae1e33f..921bf13d76 100644
--- a/gnu/packages/django.scm
+++ b/gnu/packages/django.scm
@@ -7,6 +7,7 @@
;;; Copyright © 2018 Vijayalakshmi Vedantham <vijimay12@gmail.com>
;;; Copyright © 2019 Sam <smbaines8@gmail.com>
;;; Copyright © 2020, 2021 Marius Bakke <marius@gnu.org>
+;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -64,8 +65,7 @@
;; The test-suite tests timezone-dependent functions, thus tzdata
;; needs to be available.
(setenv "TZDIR"
- (string-append (assoc-ref inputs "tzdata")
- "/share/zoneinfo"))
+ (search-input-directory inputs "share/zoneinfo"))
;; Disable test for incorrect timezone: it only raises the
;; expected error when /usr/share/zoneinfo exists, even though
@@ -75,24 +75,13 @@
(substitute* "tests/settings_tests/tests.py"
((".*def test_incorrect_timezone.*" all)
(string-append " @unittest.skipIf(True, 'Disabled by Guix')\n"
- all)))
-
- ;; Preserve the PYTHONPATH created by Guix when running the tests.
- (substitute* "tests/admin_scripts/tests.py"
- (("python_path = \\[")
- (string-append "python_path = ['"
- (string-join
- (string-split (getenv "PYTHONPATH") #\:)
- "','")
- "', ")))
-
- #t))
+ all)))))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(if tests?
(with-directory-excursion "tests"
- (setenv "PYTHONPATH"
- (string-append "..:" (getenv "PYTHONPATH")))
+ ;; Tests expect PYTHONPATH to contain the root directory.
+ (setenv "PYTHONPATH" "..")
(invoke "python" "runtests.py"
;; By default tests run in parallel, which may cause
;; various race conditions. Run sequentially for
@@ -372,31 +361,26 @@ size and quality.")
(replace 'check
(lambda* (#:key tests? inputs outputs #:allow-other-keys)
(if tests?
- (begin
- (add-installed-pythonpath inputs outputs)
- (setenv "PYTHONPATH"
- (string-append ".:" ;for pytest_django_test
- (getenv "PYTHONPATH")))
- (setenv "PYTEST_DJANGO_TEST_RUNNER" "pytest")
- (setenv "DJANGO_SETTINGS_MODULE"
- "pytest_django_test.settings_sqlite_file")
- (invoke "pytest" "-vv" "-k"
- ;; FIXME: these tests fail to locate Django templates ...
- (string-append "not test_django_not_loaded_without_settings"
- " and not test_settings"
- ;; ... and this does not discover
- ;; 'pytest_django_test'.
- " and not test_urls_cache_is_cleared")))
- (format #t "test suite not run~%"))
- #t)))))
+ (begin
+ (setenv "PYTEST_DJANGO_TEST_RUNNER" "pytest")
+ (setenv "DJANGO_SETTINGS_MODULE"
+ "pytest_django_test.settings_sqlite_file")
+ (invoke "python" "-m" "pytest" "-vv" "-k"
+ ;; FIXME: these tests fail to locate Django templates ...
+ (string-append "not test_django_not_loaded_without_settings"
+ " and not test_settings"
+ ;; ... and this does not discover
+ ;; 'pytest_django_test'.
+ " and not test_urls_cache_is_cleared")))
+ (format #t "test suite not run~%")))))))
(native-inputs
`(("python-django" ,python-django)
("python-setuptools-scm" ,python-setuptools-scm)
;; For tests.
("python-pytest-xdist" ,python-pytest-xdist-next)))
(propagated-inputs
- `(("python-pytest" ,python-pytest-6)))
- (home-page "https://pytest-django.readthedocs.io/")
+ `(("python-pytest" ,python-pytest)))
+ (home-page "https://pytest-django.readthedocs.org/")
(synopsis "Django plugin for py.test")
(description "Pytest-django is a plugin for py.test that provides a set of
useful tools for testing Django applications and projects.")
@@ -757,9 +741,6 @@ project aims to bulk update given objects using one query over Django ORM.")
(modify-phases %standard-phases
(replace 'check
(lambda _
- (setenv "PYTHONPATH"
- (string-append "./build/lib:"
- (getenv "PYTHONPATH")))
(invoke "coverage" "run" "--source" "contact_form"
"runtests.py"))))))
(native-inputs
@@ -818,14 +799,9 @@ entries, photos, book chapters, or anything else.")
(which "env")))))
(replace 'check
(lambda*(#:key tests? #:allow-other-keys)
- (or
- (not tests?)
- (begin
- (setenv "PYTHONPATH"
- (string-append (getcwd) ":"
- (getenv "PYTHONPATH")))
- (setenv "DJANGO_SETTINGS_MODULE" "tests.settings")
- (invoke "django-admin" "test" "tests"))))))))
+ (when tests?
+ (setenv "DJANGO_SETTINGS_MODULE" "tests.settings")
+ (invoke "django-admin" "test" "tests")))))))
(native-inputs
`(("python-django" ,python-django)))
(propagated-inputs
@@ -952,10 +928,8 @@ using Python multiprocessing.")
`(#:phases (modify-phases %standard-phases
(replace 'check
(lambda _
- (setenv "PYTHONPATH" (string-append "./test_project:"
- "./build/lib:.:"
- (getenv "PYTHONPATH")))
- (invoke "django-admin.py" "test" "--settings=settings"))))))
+ (invoke "python" "django-admin.py"
+ "test" "--settings=settings"))))))
(native-inputs
`(("python-django" ,python-django)))
(home-page "https://github.com/jazzband/django-sortedm2m")
@@ -981,10 +955,8 @@ the order of added relations.")
'(#:phases (modify-phases %standard-phases
(replace 'check
(lambda _
- (setenv "PYTHONPATH" (string-append ".:"
- (getenv "PYTHONPATH")))
(setenv "DJANGO_SETTINGS_MODULE" "tests.test_settings")
- (invoke "django-admin.py" "test" "-v2"))))))
+ (invoke "python" "django-admin.py" "test" "-v2"))))))
(native-inputs
`(("python-django" ,python-django)))
(home-page "https://github.com/django-compressor/django-appconf")
@@ -1016,9 +988,7 @@ name is purely coincidental.")
'(#:phases (modify-phases %standard-phases
(replace 'check
(lambda _
- (setenv "PYTHONPATH"
- (string-append "./tests/test_project:./build/lib:"
- (getenv "PYTHONPATH")))
+ (setenv "PYTHONPATH" "./tests/test_project")
(setenv "DJANGO_SETTINGS_MODULE" "project.settings")
(invoke "pytest" "-vv"))))))
(native-inputs
@@ -1335,15 +1305,11 @@ to ElasticSearch.")
;; Do not depend on compatibility package for old
;; Python versions.
(substitute* "requirements.txt"
- (("enum-compat") ""))
- #t))
+ (("enum-compat") ""))))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(if tests?
(begin
- (setenv "PYTHONPATH"
- (string-append "./build/lib:.:"
- (getenv "PYTHONPATH")))
(setenv "DJANGO_SETTINGS_MODULE"
"test_project.settings")
(invoke "pytest" "-vv" "--doctest-modules"