From 9bdfae0c1b9ea5533d89736704f9eb872d5c40dc Mon Sep 17 00:00:00 2001 From: Miro HronĨok Date: Mar 12 2024 18:49:42 +0000 Subject: Add a tests bcond (tests are enabled by default) [skip changelog] --- diff --git a/python-django.spec b/python-django.spec index 071f86d..d889f45 100644 --- a/python-django.spec +++ b/python-django.spec @@ -22,6 +22,9 @@ Source0: %{pypi_source %{pkgname} %{real_version}} # + /builddir/build/BUILD/Django-4.2.1/tests/settings_tests/tests.py Patch: dirty-hack-remove-assert.patch +# This allows to build the package without tests, e.g. when bootstrapping new Python version +%bcond tests 1 + BuildArch: noarch %global _description %{expand: @@ -89,7 +92,7 @@ sed -i '/^black\b/d' tests/requirements/py3.txt sed -i '/^blacken-docs\b/d' docs/requirements.txt %generate_buildrequires -%pyproject_buildrequires -r tests/requirements/{py3,postgres,mysql,oracle}.txt docs/requirements.txt +%pyproject_buildrequires -r %{?with_tests:tests/requirements/{py3,postgres,mysql,oracle}.txt} docs/requirements.txt %build %pyproject_wheel @@ -127,6 +130,16 @@ find %{buildroot} -name "*.po" | xargs rm -f sed -i '/.po$/d' %{pyproject_files} %check +# many contrib modules assume a configured app, "Requested setting INSTALLED_APPS..." +# the rest needs optional dependencies +%{pyproject_check_import \ + -e 'django.contrib.*' \ + -e 'django.core.serializers.pyyaml' \ + -e 'django.db.backends.mysql*' \ + -e 'django.db.backends.oracle*' \ + -e 'django.db.backends.postgresql*'} + +%if %{with tests} cd %{_builddir}/%{pkgname}-%{real_version} export PYTHONPATH=$(pwd) cd tests @@ -137,6 +150,7 @@ cd tests %if v"%{python3_version}" >= v"3.12" -k "not test_safe_mime_multipart and not test_unicode_address_header" %endif +%endif %files bash-completion %{bash_completions_dir}/*