From 7da22ed73a6c6619068c977f589ac60b3cffd52efc6df3e17999178987aa79f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20S=C3=BAkup?= Date: Wed, 15 Jan 2020 14:34:23 +0000 Subject: [PATCH] - add pyyaml53.patch - fix tests with PyYAML 5.3 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:django/python-Django?expand=0&rev=50 --- python-Django.changes | 5 +++ python-Django.spec | 4 ++- pyyaml53.patch | 76 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 pyyaml53.patch diff --git a/python-Django.changes b/python-Django.changes index a6c4053..7ded6d2 100644 --- a/python-Django.changes +++ b/python-Django.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Jan 15 14:25:13 UTC 2020 - Ondřej Súkup + +- add pyyaml53.patch - fix tests with PyYAML 5.3 + ------------------------------------------------------------------- Sun Dec 29 11:00:47 UTC 2019 - Ondřej Súkup diff --git a/python-Django.spec b/python-Django.spec index 852c57c..40f1dfc 100644 --- a/python-Django.spec +++ b/python-Django.spec @@ -1,7 +1,7 @@ # # spec file for package python-Django # -# Copyright (c) 2019 SUSE LLC +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -35,6 +35,7 @@ Source99: python-Django-rpmlintrc Patch0: i18n_test.patch Patch1: test_clear_site_cache-sort.patch Patch2: fix-selenium-test.patch +Patch3: pyyaml53.patch BuildRequires: %{python_module Jinja2 >= 2.9.2} BuildRequires: %{python_module Pillow} BuildRequires: %{python_module PyYAML} @@ -100,6 +101,7 @@ echo "`grep -e '^[0-9a-f]\{64\} Django-%{version}.tar.gz' %{SOURCE1} | cut -c1- %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 chmod a-x django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js %build diff --git a/pyyaml53.patch b/pyyaml53.patch new file mode 100644 index 0000000..f39da0d --- /dev/null +++ b/pyyaml53.patch @@ -0,0 +1,76 @@ +From 4a6824e450e15aeb3558ba80b1b314e33a6e7b0b Mon Sep 17 00:00:00 2001 +From: Mariusz Felisiak +Date: Tue, 7 Jan 2020 08:59:22 +0100 +Subject: [PATCH] Fixed timezones tests for PyYAML 5.3+. + +--- + tests/timezones/tests.py | 28 ++++++++++++++++++++++------ + 1 file changed, 22 insertions(+), 6 deletions(-) + +diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py +index 67bac731f7b5..a211a43de0b4 100644 +--- a/tests/timezones/tests.py ++++ b/tests/timezones/tests.py +@@ -32,6 +32,12 @@ + AllDayEvent, Event, MaybeEvent, Session, SessionEvent, Timestamp, + ) + ++try: ++ import yaml ++ HAS_YAML = True ++except ImportError: ++ HAS_YAML = False ++ + # These tests use the EAT (Eastern Africa Time) and ICT (Indochina Time) + # who don't have Daylight Saving Time, so we can represent them easily + # with fixed offset timezones and use them directly as tzinfo in the +@@ -607,9 +613,10 @@ class SerializationTests(SimpleTestCase): + + # Backend-specific notes: + # - JSON supports only milliseconds, microseconds will be truncated. +- # - PyYAML dumps the UTC offset correctly for timezone-aware datetimes, +- # but when it loads this representation, it subtracts the offset and +- # returns a naive datetime object in UTC. See ticket #18867. ++ # - PyYAML dumps the UTC offset correctly for timezone-aware datetimes. ++ # When PyYAML < 5.3 loads this representation, it subtracts the offset ++ # and returns a naive datetime object in UTC. PyYAML 5.3+ loads timezones ++ # correctly. + # Tests are adapted to take these quirks into account. + + def assert_python_contains_datetime(self, objects, dt): +@@ -696,7 +703,10 @@ def test_aware_datetime_with_microsecond(self): + data = serializers.serialize('yaml', [Event(dt=dt)], default_flow_style=None) + self.assert_yaml_contains_datetime(data, "2011-09-01 17:20:30.405060+07:00") + obj = next(serializers.deserialize('yaml', data)).object +- self.assertEqual(obj.dt.replace(tzinfo=UTC), dt) ++ if HAS_YAML and yaml.__version__ < '5.3': ++ self.assertEqual(obj.dt.replace(tzinfo=UTC), dt) ++ else: ++ self.assertEqual(obj.dt, dt) + + def test_aware_datetime_in_utc(self): + dt = datetime.datetime(2011, 9, 1, 10, 20, 30, tzinfo=UTC) +@@ -744,7 +754,10 @@ def test_aware_datetime_in_local_timezone(self): + data = serializers.serialize('yaml', [Event(dt=dt)], default_flow_style=None) + self.assert_yaml_contains_datetime(data, "2011-09-01 13:20:30+03:00") + obj = next(serializers.deserialize('yaml', data)).object +- self.assertEqual(obj.dt.replace(tzinfo=UTC), dt) ++ if HAS_YAML and yaml.__version__ < '5.3': ++ self.assertEqual(obj.dt.replace(tzinfo=UTC), dt) ++ else: ++ self.assertEqual(obj.dt, dt) + + def test_aware_datetime_in_other_timezone(self): + dt = datetime.datetime(2011, 9, 1, 17, 20, 30, tzinfo=ICT) +@@ -768,7 +781,10 @@ def test_aware_datetime_in_other_timezone(self): + data = serializers.serialize('yaml', [Event(dt=dt)], default_flow_style=None) + self.assert_yaml_contains_datetime(data, "2011-09-01 17:20:30+07:00") + obj = next(serializers.deserialize('yaml', data)).object +- self.assertEqual(obj.dt.replace(tzinfo=UTC), dt) ++ if HAS_YAML and yaml.__version__ < '5.3': ++ self.assertEqual(obj.dt.replace(tzinfo=UTC), dt) ++ else: ++ self.assertEqual(obj.dt, dt) + + + @override_settings(DATETIME_FORMAT='c', TIME_ZONE='Africa/Nairobi', USE_L10N=False, USE_TZ=True)