diff options
author | Patrick McLean <patrick.mclean@sony.com> | 2019-11-21 15:51:12 -0800 |
---|---|---|
committer | Patrick McLean <chutzpah@gentoo.org> | 2019-11-21 15:55:12 -0800 |
commit | 01360803571fe4a544dd2d0778e8d1f5c1147d1f (patch) | |
tree | 1582ef755d55280cb3e9fd63aa107b6c3cb2a105 /dev-python/freezegun | |
parent | dev-python/python-dateutil: Verbump to 2.8.1, add py38 (diff) | |
download | gentoo-01360803571fe4a544dd2d0778e8d1f5c1147d1f.tar.gz gentoo-01360803571fe4a544dd2d0778e8d1f5c1147d1f.tar.bz2 gentoo-01360803571fe4a544dd2d0778e8d1f5c1147d1f.zip |
dev-python/freezegun: Version bump to 0.3.12, add py38
Copyright: Sony Interactive Entertainment Inc.
Package-Manager: Portage-2.3.79, Repoman-2.3.18
Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
Diffstat (limited to 'dev-python/freezegun')
-rw-r--r-- | dev-python/freezegun/Manifest | 1 | ||||
-rw-r--r-- | dev-python/freezegun/files/freezegun-0.3.12-py38.patch | 122 | ||||
-rw-r--r-- | dev-python/freezegun/files/freezegun-0.3.12-tests.patch | 13 | ||||
-rw-r--r-- | dev-python/freezegun/freezegun-0.3.12.ebuild | 46 |
4 files changed, 182 insertions, 0 deletions
diff --git a/dev-python/freezegun/Manifest b/dev-python/freezegun/Manifest index 42cafd7ad325..6810f911570c 100644 --- a/dev-python/freezegun/Manifest +++ b/dev-python/freezegun/Manifest @@ -1,2 +1,3 @@ DIST freezegun-0.3.10.tar.gz 20398 BLAKE2B 971f4f3de565878b8a1e4671160f41cc7c558f5c848f5c79dfc48e3f3e3cb71ff9c71090705167d4252edbfee040ef52a7eafd33073011c07337311a7e0ec366 SHA512 64364459dc72484e2124a20a0a84d2b88617efd0578fba687adb51635d578a1e36a00cb119998082610c608e7b6c3589bff5424e38845bad026e85449c8065a5 DIST freezegun-0.3.11.tar.gz 23382 BLAKE2B 759cc0355c8600fc46124dfb73b46a771de5cae4e66f5826c175295da96190920d7ff45b6457a061276c0c698bd448e294f29f3b89a0ed8fe76db58e1180b080 SHA512 e8b392176641d52f6ed795c9af5fbc0a62892aeedf32b42375b56ab44a9ad7a5ecd3bb81363ed0ae65204aff2ef894cd7f2e17f42be72f31d3409b2bffa59ab8 +DIST freezegun-0.3.12.tar.gz 24346 BLAKE2B 09d7c662a82d7b7fa6ae56c09bff0d73e2b63fba2b492620cd8e68ee06a15129a7e901418d1881e65b440babcfe0d014ad3574ab8dd2c7eab8486b3d868273ac SHA512 f7d98ea84735b24380fa53e1e62622fe91be5a35cb75221ca4cb02418add9b0a4add9b2f691242be75acbc45d4745fef82ffe3c89890dcdffa4405940e527af4 diff --git a/dev-python/freezegun/files/freezegun-0.3.12-py38.patch b/dev-python/freezegun/files/freezegun-0.3.12-py38.patch new file mode 100644 index 000000000000..d35303bf9fe5 --- /dev/null +++ b/dev-python/freezegun/files/freezegun-0.3.12-py38.patch @@ -0,0 +1,122 @@ +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 new file mode 100644 index 000000000000..08543fc7d595 --- /dev/null +++ b/dev-python/freezegun/files/freezegun-0.3.12-tests.patch @@ -0,0 +1,13 @@ +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): diff --git a/dev-python/freezegun/freezegun-0.3.12.ebuild b/dev-python/freezegun/freezegun-0.3.12.ebuild new file mode 100644 index 000000000000..d33a914e745d --- /dev/null +++ b/dev-python/freezegun/freezegun-0.3.12.ebuild @@ -0,0 +1,46 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 +PYTHON_COMPAT=( python{2_7,3_{5,6,7,8}} pypy{,3} ) + +inherit distutils-r1 + +DESCRIPTION="Let your Python tests travel through time" +HOMEPAGE="https://github.com/spulec/freezegun" +SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz" + +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos" +IUSE="test" + +RDEPEND=" + >dev-python/python-dateutil-2.0[${PYTHON_USEDEP}] + dev-python/six[${PYTHON_USEDEP}] +" +DEPEND="${RDEPEND} + dev-python/setuptools[${PYTHON_USEDEP}] + test? ( + $(python_gen_impl_dep sqlite) + dev-python/mock[${PYTHON_USEDEP}] + dev-python/nose[${PYTHON_USEDEP}] + ) +" + +PATCHES=( + # pulled from upstream git, will be in next release + "${FILESDIR}/freezegun-0.3.12-py38.patch" + + # test fixes + "${FILESDIR}/freezegun-0.3.12-tests.patch" +) + +distutils_enable_tests pytest + +python_prepare() { + # optional and only works with python3 + if ! python_is_python3; then + rm ${PN}/_async.py || die + fi +} |