diff options
Diffstat (limited to 'dev-python/freezegun/files')
3 files changed, 0 insertions, 193 deletions
diff --git a/dev-python/freezegun/files/freezegun-0.3.10-py37.patch b/dev-python/freezegun/files/freezegun-0.3.10-py37.patch deleted file mode 100644 index aa3bd536e09e..000000000000 --- a/dev-python/freezegun/files/freezegun-0.3.10-py37.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 4fdad69659f15a9e62cf4f6c15c9f319276cf9b0 Mon Sep 17 00:00:00 2001 -From: Jonas Obrist <jonas.obrist@hde.co.jp> -Date: Tue, 6 Mar 2018 12:21:38 +0900 -Subject: [PATCH] add support for Python 3.7 uuid module changes - -Python 3.7 removed uuid._uuid_generate_time. It now has -uuid._load_system_functions and uuid._generate_time_safe. -_generate_time_safe is set by calling _load_system_functions (subsequent -calls to that function are no-op). This change detects the missing -uuid._uuid_generate_time attribute and uses the new attribute/function -if they're missing. ---- - freezegun/api.py | 14 +++++++++++--- - 1 file changed, 11 insertions(+), 3 deletions(-) - -diff --git a/freezegun/api.py b/freezegun/api.py -index eb09932..a88a392 100644 ---- a/freezegun/api.py -+++ b/freezegun/api.py -@@ -27,8 +27,14 @@ _real_time_object_ids = set(id(obj) for obj in real_date_objects) - - try: - real_uuid_generate_time = uuid._uuid_generate_time --except (AttributeError, ImportError): -+ uuid_generate_time_attr = '_uuid_generate_time' -+except AttributeError: -+ uuid._load_system_functions() -+ real_uuid_generate_time = uuid._generate_time_safe -+ uuid_generate_time_attr = '_generate_time_safe' -+except ImportError: - real_uuid_generate_time = None -+ uuid_generate_time_attr = None - - try: - real_uuid_create = uuid._UuidCreate -@@ -482,7 +488,8 @@ class _freeze_time(object): - time.localtime = fake_localtime - time.gmtime = fake_gmtime - time.strftime = fake_strftime -- uuid._uuid_generate_time = None -+ if uuid_generate_time_attr: -+ setattr(uuid, uuid_generate_time_attr, None) - uuid._UuidCreate = None - uuid._last_timestamp = None - -@@ -573,7 +580,8 @@ class _freeze_time(object): - time.localtime = time.localtime.previous_localtime_function - time.strftime = time.strftime.previous_strftime_function - -- uuid._uuid_generate_time = real_uuid_generate_time -+ if uuid_generate_time_attr: -+ setattr(uuid, uuid_generate_time_attr, real_uuid_generate_time) - uuid._UuidCreate = real_uuid_create - uuid._last_timestamp = None - --- -2.18.0 - diff --git a/dev-python/freezegun/files/freezegun-0.3.12-py38.patch b/dev-python/freezegun/files/freezegun-0.3.12-py38.patch deleted file mode 100644 index d35303bf9fe5..000000000000 --- a/dev-python/freezegun/files/freezegun-0.3.12-py38.patch +++ /dev/null @@ -1,122 +0,0 @@ -commit 4d998c9d6b130ed4e2d54cb96b010fec749a9c59 -Author: xtreak <tir.karthi@gmail.com> -Date: Wed Jun 19 14:54:22 2019 +0000 - - Patch time.time_ns to support Python 3.8 - -diff --git a/CHANGELOG b/CHANGELOG -index efac4d3..14d96be 100644 ---- a/CHANGELOG -+++ b/CHANGELOG -@@ -11,6 +11,7 @@ Latest - * Ignore Selenium - * Move to pytest - * Conditionally patch time.clock -+* Patch time.time_ns added in Python 3.7 - - 0.3.11 - ------ -@@ -57,4 +58,4 @@ Latest - - * Add `tick` argument to allow time to move forward - * Performance improvements --* Fix timezone example in README -\ No newline at end of file -+* Fix timezone example in README -diff --git a/freezegun/api.py b/freezegun/api.py -index 5e7d7fa..bc61270 100644 ---- a/freezegun/api.py -+++ b/freezegun/api.py -@@ -20,6 +20,7 @@ try: - except ImportError: - MayaDT = None - -+_TIME_NS_PRESENT = hasattr(time, 'time_ns') - - real_time = time.time - real_localtime = time.localtime -@@ -28,6 +29,11 @@ real_strftime = time.strftime - real_date = datetime.date - real_datetime = datetime.datetime - real_date_objects = [real_time, real_localtime, real_gmtime, real_strftime, real_date, real_datetime] -+ -+if _TIME_NS_PRESENT: -+ real_time_ns = time.time_ns -+ real_date_objects.append(real_time_ns) -+ - _real_time_object_ids = set(id(obj) for obj in real_date_objects) - - # time.clock is deprecated and was removed in Python 3.8 -@@ -175,6 +181,12 @@ def fake_time(): - current_time = get_current_time() - return calendar.timegm(current_time.timetuple()) + current_time.microsecond / 1000000.0 - -+if _TIME_NS_PRESENT: -+ def fake_time_ns(): -+ if _should_use_real_time(): -+ return real_time_ns() -+ return int(int(fake_time()) * 1e9) -+ - - def fake_localtime(t=None): - if t is not None: -@@ -331,7 +343,7 @@ class FakeDatetime(with_metaclass(FakeDatetimeMeta, real_datetime, FakeDate)): - - def date(self): - return date_to_fakedate(self) -- -+ - @property - def nanosecond(self): - try: -@@ -599,6 +611,10 @@ class _freeze_time(object): - ('real_time', real_time, fake_time), - ] - -+ if _TIME_NS_PRESENT: -+ time.time_ns = fake_time_ns -+ to_patch.append(('real_time_ns', real_time_ns, fake_time_ns)) -+ - if real_clock is not None: - # time.clock is deprecated and was removed in Python 3.8 - time.clock = fake_clock -@@ -741,7 +757,7 @@ def freeze_time(time_to_freeze=None, tz_offset=0, ignore=None, tick=False, as_ar - ignore.append('selenium') - ignore.append('_pytest.terminal.') - ignore.append('_pytest.runner.') -- -+ - return _freeze_time(time_to_freeze, tz_offset, ignore, tick, as_arg, auto_tick_seconds) - - -diff --git a/tests/test_datetimes.py b/tests/test_datetimes.py -index cfef4a1..688fdce 100644 ---- a/tests/test_datetimes.py -+++ b/tests/test_datetimes.py -@@ -19,6 +19,7 @@ except ImportError: - - # time.clock was removed in Python 3.8 - HAS_CLOCK = hasattr(time, 'clock') -+HAS_TIME_NS = hasattr(time, 'time_ns') - - class temp_locale(object): - """Temporarily change the locale.""" -@@ -656,3 +657,18 @@ def test_should_use_real_time(): - assert time.gmtime() != expected_frozen_gmt - if HAS_CLOCK: - assert time.clock() != expected_clock -+ -+ -+@pytest.mark.skipif(not HAS_TIME_NS, -+ reason="time.time_ns is present only on 3.7 and above") -+def test_time_ns(): -+ freezer = freeze_time("2012-01-14") -+ local_time = datetime.datetime(2012, 1, 14) -+ utc_time = local_time - datetime.timedelta(seconds=time.timezone) -+ expected_timestamp = time.mktime(utc_time.timetuple()) -+ -+ freezer.start() -+ assert time.time() == expected_timestamp -+ assert time.time_ns() == expected_timestamp * 1e9 -+ freezer.stop() -+ assert time.time() != expected_timestamp diff --git a/dev-python/freezegun/files/freezegun-0.3.12-tests.patch b/dev-python/freezegun/files/freezegun-0.3.12-tests.patch deleted file mode 100644 index 08543fc7d595..000000000000 --- a/dev-python/freezegun/files/freezegun-0.3.12-tests.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/tests/test_datetimes.py b/tests/test_datetimes.py -index 688fdce..a61484d 100644 ---- a/tests/test_datetimes.py -+++ b/tests/test_datetimes.py -@@ -18,7 +18,7 @@ except ImportError: - maya = None - - # time.clock was removed in Python 3.8 --HAS_CLOCK = hasattr(time, 'clock') -+HAS_CLOCK = hasattr(time, 'clock') and getattr(time, 'clock') is not None - HAS_TIME_NS = hasattr(time, 'time_ns') - - class temp_locale(object): |