From d67bd37e33423607b67a25704b116fb37b15a2f974de84055624e00eba66efa6 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 14 Jan 2026 20:22:59 +0000 Subject: [PATCH] =?UTF-8?q?-=20Update=20to=203.1.0=20=20=20-=20Optimize=20?= =?UTF-8?q?patching=20of=20uuid=20module.=20By=20avoiding=20using=20=20=20?= =?UTF-8?q?=20=20unittest.mock,=20this=20small=20overhead=20from=20startin?= =?UTF-8?q?g=20=20=20=20=20time=5Fmachine.travel()=20has=20been=20reduced?= =?UTF-8?q?=20about=2020x,=20from=20~600ns=20=20=20=20=20to=20~30ns=20by?= =?UTF-8?q?=20one=20benchmark.=20-=20Update=20to=203.0.0=20=20=20-=20Remov?= =?UTF-8?q?e=20mocking=20of=20time.monotonic()=20and=20time.monotonic=5Fns?= =?UTF-8?q?().=20=20=20=20=20This=20mocking=20caused=20too=20many=20issues?= =?UTF-8?q?,=20such=20as=20causing=20freezes=20=20=20=20=20in=20asyncio=20?= =?UTF-8?q?event=20loops=20(Issue=20#387),=20preventing=20=20=20=20=20pyte?= =?UTF-8?q?st-durations=20from=20timing=20tests=20correctly=20(Issue=20#50?= =?UTF-8?q?5),=20=20=20=20=20and=20triggering=20timeouts=20in=20psycopg=20?= =?UTF-8?q?(Issue=20#509).=20The=20root=20=20=20=20=20cause=20here=20is=20?= =?UTF-8?q?that=20mocking=20the=20monotonic=20clock=20breaks=20its=20=20?= =?UTF-8?q?=20=20=20contract,=20allowing=20it=20to=20move=20backwards=20wh?= =?UTF-8?q?en=20it=E2=80=99s=20meant=20to=20=20=20=20=20only=20move=20forw?= =?UTF-8?q?ards.=20=20=20=20=20As=20an=20alternative,=20use=20unittest.moc?= =?UTF-8?q?k=20to=20mock=20the=20monotonic=20=20=20=20=20function=20for=20?= =?UTF-8?q?the=20specific=20tested=20modules=20that=20need=20it.=20That=20?= =?UTF-8?q?=20=20=20=20means=20that=20your=20code=20should=20import=20mono?= =?UTF-8?q?tonic()=20or=20=20=20=20=20monotonic=5Fns()=20directly,=20so=20?= =?UTF-8?q?that=20your=20tests=20can=20mock=20it=20in=20=20=20=20=20those?= =?UTF-8?q?=20places=20only.=20=20=20-=20Parse=20str=20destinations=20with?= =?UTF-8?q?=20datetime.fromisoformat()=20first,=20=20=20=20=20before=20fal?= =?UTF-8?q?ling=20back=20to=20dateutil=20if=20installed.=20=20=20=20=20dat?= =?UTF-8?q?etime.fromisoformat()=20can=20parse=20most=20valid=20ISO=208601?= =?UTF-8?q?=20=20=20=20=20formats,=20with=20better=20performance=20and=20n?= =?UTF-8?q?o=20extra=20dependencies.=20=20=20-=20Make=20the=20dependency?= =?UTF-8?q?=20on=20dateutil=20optional.=20=20=20-=20Rename=20the=20Coordin?= =?UTF-8?q?ates=20class=20to=20Traveller,=20to=20match=20the=20=20=20=20?= =?UTF-8?q?=20recommended=20context=20manager=20variable=20name.=20=20=20-?= =?UTF-8?q?=20Drop=20Python=203.9=20support.=20=20=20-=20Make=20the=20esca?= =?UTF-8?q?pe=5Fhatch=20functions=20raise=20ValueError=20when=20called=20?= =?UTF-8?q?=20=20=20=20outside=20of=20time-travelling,=20rather=20than=20t?= =?UTF-8?q?riggering=20=20=20=20=20segmentation=20faults.=20-=20Update=20t?= =?UTF-8?q?o=202.19.0=20=20=20-=20Add=20marker=20support=20to=20the=20pyte?= =?UTF-8?q?st=20plugin.=20Decorate=20tests=20with=20=20=20=20=20@pytest.ma?= =?UTF-8?q?rk.time=5Fmachine()=20to=20set=20time=20during=20a?= =?UTF-8?q?=20test,=20=20=20=20=20affecting=20function-level=20fixtures=20?= =?UTF-8?q?as=20well.=20=20=20-=20Add=20asynchronous=20context=20manager?= =?UTF-8?q?=20support=20to=20time=5Fmachine.travel().=20You=20can=20=20=20?= =?UTF-8?q?=20=20now=20use=20async=20with=20time=5Fmachine.travel(...):=20?= =?UTF-8?q?in=20asynchronous=20code,=20per=20the=20=20=20=20=20documentati?= =?UTF-8?q?on.=20=20=20-=20Import=20date=20and=20time=20functions=20once?= =?UTF-8?q?=20in=20the=20C=20extension.=20=20=20-=20This=20should=20improv?= =?UTF-8?q?e=20speed=20a=20little=20bit,=20and=20avoid=20segmentation=20fa?= =?UTF-8?q?ults=20when=20=20=20=20=20the=20functions=20have=20been=20swapp?= =?UTF-8?q?ed=20out,=20such=20as=20when=20freezegun=20is=20in=20effect.=20?= =?UTF-8?q?=20=20=20=20(time-machine=20still=20won=E2=80=99t=20apply=20if?= =?UTF-8?q?=20freezegun=20is=20in=20effect.)=20-=20Update=20to=202.18.0=20?= =?UTF-8?q?=20=20-=20Update=20the=20migration=20CLI=20to=20detect=20unitte?= =?UTF-8?q?st=20classes=20based=20on=20whether=20they=20=20=20=20=20use=20?= =?UTF-8?q?self.assert*=20methods=20like=20self.assertEqual().=20=20=20-?= =?UTF-8?q?=20Fix=20free-threaded=20Python=20warning:=20RuntimeWarning:=20?= =?UTF-8?q?The=20global=20interpreter=20=20=20=20=20lock=20(GIL)=20has=20b?= =?UTF-8?q?een=20enabled...=20as=20seen=20on=20Python=203.13+.=20=20=20-?= =?UTF-8?q?=20Add=20support=20to=20travel()=20for=20datetime=20destination?= =?UTF-8?q?s=20with=20tzinfo=20set=20to=20=20=20=20=20datetime.UTC=20(date?= =?UTF-8?q?time.timezone.utc).=20=20=20-=20Prevent=20segmentation=20faults?= =?UTF-8?q?=20in=20unlikely=20scenarios,=20such=20as=20if=20the=20=20=20?= =?UTF-8?q?=20=20time=5Fmachine=20module=20cannot=20be=20imported.=20=20?= =?UTF-8?q?=20-=20Make=20travel()=20fully=20unpatch=20date=20and=20time=20?= =?UTF-8?q?functions=20when=20travel=20ends.=20This=20=20=20=20=20may=20fi?= =?UTF-8?q?x=20certain=20edge=20cases.=20-=20Update=20to=202.17.0=20=20=20?= =?UTF-8?q?-=20Include=20wheels=20for=20Python=203.14.=20=20=20-=20Support?= =?UTF-8?q?=20free-threaded=20Python.=20=20=20-=20Add=20a=20new=20CLI=20fo?= =?UTF-8?q?r=20migrating=20code=20from=20freezegun=20to=20time-machine.=20?= =?UTF-8?q?=20=20-=20Install=20with=20pip=20install=20time-machine[cli]=20?= =?UTF-8?q?and=20run=20with=20python=20-m=20=20=20=20=20time=5Fmachine=20m?= =?UTF-8?q?igrate.=20=20=20-=20Move=20the=20documentation=20to=20Read=20th?= =?UTF-8?q?e=20Docs,=20and=20add=20a=20retro-futuristic=20logo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-time-machine?expand=0&rev=37 --- .gitattributes | 23 +++ .gitignore | 1 + python-time-machine-2.16.0.tar.gz | 3 + python-time-machine-3.1.0.tar.gz | 3 + python-time-machine.changes | 229 ++++++++++++++++++++++++++++++ python-time-machine.spec | 71 +++++++++ 6 files changed, 330 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 python-time-machine-2.16.0.tar.gz create mode 100644 python-time-machine-3.1.0.tar.gz create mode 100644 python-time-machine.changes create mode 100644 python-time-machine.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/python-time-machine-2.16.0.tar.gz b/python-time-machine-2.16.0.tar.gz new file mode 100644 index 0000000..a87de42 --- /dev/null +++ b/python-time-machine-2.16.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d2ed8ebef04133d69bce09114bbf66be0d404d725597874a644318af6e0b3e28 +size 30522 diff --git a/python-time-machine-3.1.0.tar.gz b/python-time-machine-3.1.0.tar.gz new file mode 100644 index 0000000..2585e1f --- /dev/null +++ b/python-time-machine-3.1.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ccc9add7f678a2652249d12efea446db0540acc90240ae9327d2fdcbba4f920 +size 75765 diff --git a/python-time-machine.changes b/python-time-machine.changes new file mode 100644 index 0000000..1b56361 --- /dev/null +++ b/python-time-machine.changes @@ -0,0 +1,229 @@ +------------------------------------------------------------------- +Tue Dec 9 21:22:28 UTC 2025 - Matej Cepl + +- Update to 3.1.0 + - Optimize patching of uuid module. By avoiding using + unittest.mock, this small overhead from starting + time_machine.travel() has been reduced about 20x, from ~600ns + to ~30ns by one benchmark. +- Update to 3.0.0 + - Remove mocking of time.monotonic() and time.monotonic_ns(). + This mocking caused too many issues, such as causing freezes + in asyncio event loops (Issue #387), preventing + pytest-durations from timing tests correctly (Issue #505), + and triggering timeouts in psycopg (Issue #509). The root + cause here is that mocking the monotonic clock breaks its + contract, allowing it to move backwards when it’s meant to + only move forwards. + As an alternative, use unittest.mock to mock the monotonic + function for the specific tested modules that need it. That + means that your code should import monotonic() or + monotonic_ns() directly, so that your tests can mock it in + those places only. + - Parse str destinations with datetime.fromisoformat() first, + before falling back to dateutil if installed. + datetime.fromisoformat() can parse most valid ISO 8601 + formats, with better performance and no extra dependencies. + - Make the dependency on dateutil optional. + - Rename the Coordinates class to Traveller, to match the + recommended context manager variable name. + - Drop Python 3.9 support. + - Make the escape_hatch functions raise ValueError when called + outside of time-travelling, rather than triggering + segmentation faults. +- Update to 2.19.0 + - Add marker support to the pytest plugin. Decorate tests with + @pytest.mark.time_machine() to set time during a test, + affecting function-level fixtures as well. + - Add asynchronous context manager support to time_machine.travel(). You can + now use async with time_machine.travel(...): in asynchronous code, per the + documentation. + - Import date and time functions once in the C extension. + - This should improve speed a little bit, and avoid segmentation faults when + the functions have been swapped out, such as when freezegun is in effect. + (time-machine still won’t apply if freezegun is in effect.) +- Update to 2.18.0 + - Update the migration CLI to detect unittest classes based on whether they + use self.assert* methods like self.assertEqual(). + - Fix free-threaded Python warning: RuntimeWarning: The global interpreter + lock (GIL) has been enabled... as seen on Python 3.13+. + - Add support to travel() for datetime destinations with tzinfo set to + datetime.UTC (datetime.timezone.utc). + - Prevent segmentation faults in unlikely scenarios, such as if the + time_machine module cannot be imported. + - Make travel() fully unpatch date and time functions when travel ends. This + may fix certain edge cases. +- Update to 2.17.0 + - Include wheels for Python 3.14. + - Support free-threaded Python. + - Add a new CLI for migrating code from freezegun to time-machine. + - Install with pip install time-machine[cli] and run with python -m + time_machine migrate. + - Move the documentation to Read the Docs, and add a retro-futuristic logo. + +------------------------------------------------------------------- +Wed Oct 30 19:50:38 UTC 2024 - Dirk Müller + +- update to 2.16.0: + * Drop Python 3.8 support. + * Include wheels for Python 3.13. + +------------------------------------------------------------------- +Sun Jun 30 08:25:19 UTC 2024 - Dirk Müller + +- update to 2.14.2: + * Fix SystemError on Python 3.13 and Windows when starting time + travelling. + +------------------------------------------------------------------- +Sat Apr 20 08:01:44 UTC 2024 - Dirk Müller + +- update to 2.14.1: + * Fix segmentation fault when the first travel() call in a + process uses a timedelta. + +------------------------------------------------------------------- +Thu Mar 14 08:17:15 UTC 2024 - Dirk Müller + +- update to 2.14.0: + * Fix utcfromtimestamp() warning on Python 3.12+. + * Fix utcfromtimestamp() warning on Python 3.12+. + * Fix class decorator for classmethod overrides. + * Avoid calling deprecated uuid._load_system_functions() on + Python 3.9+. + * Avoid calling deprecated uuid._load_system_functions() on + Python 3.9+. + * Thanks to Nikita Sobolev for the ping in CPython Issue + * Support Python 3.13 alpha 4. + +------------------------------------------------------------------- +Thu Nov 9 09:05:38 UTC 2023 - ecsos + +- Update to 2.13.0 + - Add support for datetime.timedelta to time_machine.travel(). + - Fix documentation about using local time for naive date(time) strings. + - Add shift() method to the time_machine pytest fixture. + - Mock time.monotonic() and time.monotonic_ns(). + They return the values of time.time() and time.time_ns() + respectively, rather than real monotonic clocks. +- Changes from 2.12.0 + - Include wheels for Python 3.12. +- Changes from 2.11.0 + - Drop Python 3.7 support. +- Changes from 2.10.0 + - Support Python 3.12. + +------------------------------------------------------------------- +Fri Jun 9 06:20:34 UTC 2023 - ecsos + +- Add %{?sle15_python_module_pythons} + +------------------------------------------------------------------- +Wed May 31 09:26:06 UTC 2023 - Ben Greiner + +- Move to PEP517 +- Do not use pytzdata, but system timezone directly +- Don't catchall sitearch + +------------------------------------------------------------------- +Sat May 27 19:44:39 UTC 2023 - Dirk Müller + +- update to 2.9.0: + * Explicitly error when attempting to install on PyPy. + +------------------------------------------------------------------- +Tue Apr 11 08:32:21 UTC 2023 - Dominique Leuenberger + +- BuildRequire python38-backports.zoneinfo only when python38-base + is present in the buildsystem: fix build on distros where python + 3.8 is no longer in the supported set of python interpreters. + +------------------------------------------------------------------- +Sat Oct 29 16:04:03 UTC 2022 - Yogalakshmi Arunachalam + +- Update to version 2.8.2 + * Improve type hints for time_machine.travel() to preserve the types of the wrapped function/coroutine/class. + +------------------------------------------------------------------- +Thu Aug 18 07:00:08 UTC 2022 - Sebastian Wagner + +- update to version 2.8.1: + - Actually build Python 3.11 wheels. +- update to version 2.8.0: + - Build Python 3.11 wheels. +- update to version 2.7.1: + - Fix usage of ``ZoneInfo`` from the ``backports.zoneinfo`` package. + This makes ``ZoneInfo`` support work for Python < 3.9. +- update to version 2.7.0: + - Support Python 3.11 (no wheels yet, they will only be available when Python 3.11 is RC when the ABI is stable). + +------------------------------------------------------------------- +Tue Jan 11 10:01:09 UTC 2022 - Sebastian Wagner + +- Limit package to python >= 3.7 + +------------------------------------------------------------------- +Mon Jan 10 17:18:47 UTC 2022 - Sebastian Wagner + +- update to version 2.6.0: + * Drop Python 3.6 support. + +------------------------------------------------------------------- +Tue Dec 14 15:06:54 UTC 2021 - Sebastian Wagner + +- update to version 2.5.0: + * Add ``time_machine.escape_hatch``, which provides functions to bypass + time-machine. + Thanks to Matt Pegler for the feature request in `Issue #206 + `__. + +------------------------------------------------------------------- +Tue Dec 14 07:40:10 UTC 2021 - pgajdos@suse.com + +- pytest-runner is not required for build + +------------------------------------------------------------------- +Sat Nov 27 14:29:53 UTC 2021 - Sebastian Wagner + +- update to version 2.4.1: + - Build musllinux wheels. + +------------------------------------------------------------------- +Sat Sep 4 17:54:02 UTC 2021 - Sebastian Wagner + +- update to version 2.4.0: + - Support Python 3.10. + +------------------------------------------------------------------- +Fri Jul 30 08:23:35 UTC 2021 - Sebastian Wagner + +- update to version 2.3.1: + - Build universal2 wheels for Python 3.8 on macOS. +- update to version 2.3.0: + - Allow passing ``tick`` to ``Coordinates.move_to()`` and the pytest fixture’s + ``time_machine.move_to()``. This allows freezing or unfreezing of time when + travelling. + +------------------------------------------------------------------- +Sat Jul 3 13:17:35 UTC 2021 - Sebastian Wagner + +- update to version 2.2.0: + - Include type hints. + - Convert C module to use PEP 489 multi-phase extension module initialization. + This makes the module ready for Python sub-interpreters. + - Release now includes a universal2 wheel for Python 3.9 on macOS, to work on + Apple Silicon. + - Stop distributing tests to reduce package size. Tests are not intended to be + run outside of the tox setup in the repository. Repackagers can use GitHub's + tarballs per tag. + +------------------------------------------------------------------- +Sat May 29 07:50:49 UTC 2021 - Sebastian Wagner + +- skip python2 to fix leap build +- add missing group tag to fix leap build + +------------------------------------------------------------------- +Tue May 25 11:43:44 UTC 2021 - Sebastian Wagner + +- initial package for version 2.1.0. diff --git a/python-time-machine.spec b/python-time-machine.spec new file mode 100644 index 0000000..d142e42 --- /dev/null +++ b/python-time-machine.spec @@ -0,0 +1,71 @@ +# +# spec file for package python-time-machine +# +# Copyright (c) 2025 SUSE LLC and contributors +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: python-time-machine +Version: 3.1.0 +Release: 0 +Summary: Travel through time in your tests +License: MIT +Group: Development/Languages/Python +URL: https://github.com/adamchainz/time-machine +# pypi packages don't contain the tests anymore since 2.2.0, see changelog +Source: https://github.com/adamchainz/time-machine/archive/refs/tags/%{version}.tar.gz#/%{name}-%{version}.tar.gz +BuildRequires: %{python_module devel >= 3.8} +BuildRequires: %{python_module pip} +BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: fdupes +BuildRequires: python-rpm-generators +BuildRequires: python-rpm-macros +Requires: python-python-dateutil +Requires: python-tokenize-rt +Requires: timezone +# SECTION tests +BuildRequires: %{python_module backports.zoneinfo if %python-base < 3.9} +BuildRequires: %{python_module pytest} +BuildRequires: %{python_module python-dateutil} +BuildRequires: %{python_module tokenize-rt} +BuildRequires: timezone +# /SECTION +%python_subpackages + +%description +This library mocks all functions from Python's standard library that return the current date or datetime. +It can be used independently, as a function decorator, or as a context manager. + +%prep +%setup -q -n time-machine-%{version} + +%build +%pyproject_wheel + +%install +%pyproject_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} + +%check +%pytest_arch + +%files %{python_files} +%doc README.rst HISTORY.rst +%license LICENSE +%{python_sitearch}/time_machine +%{python_sitearch}/_time_machine.*.so +%{python_sitearch}/time_machine-%{version}*-info + +%changelog