diff options
author | AlexSm <alex@ydb.tech> | 2023-12-21 15:05:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-21 15:05:38 +0100 |
commit | e98bcbc74422492351c51646dba3849a138a8ffc (patch) | |
tree | 38ad7a09b1f9c201ce8a7e3d69f2017388769224 /contrib/python/freezegun/py3 | |
parent | 559d7083cd8378cb25b9e966dedcca21d413e338 (diff) | |
download | ydb-e98bcbc74422492351c51646dba3849a138a8ffc.tar.gz |
Import libs 1 (#590)
* Import libs 1
* Add new file without extension
* Add file missed in export config
Diffstat (limited to 'contrib/python/freezegun/py3')
-rw-r--r-- | contrib/python/freezegun/py3/.dist-info/METADATA | 9 | ||||
-rw-r--r-- | contrib/python/freezegun/py3/AUTHORS.rst | 1 | ||||
-rw-r--r-- | contrib/python/freezegun/py3/freezegun/__init__.py | 2 | ||||
-rw-r--r-- | contrib/python/freezegun/py3/freezegun/api.py | 28 | ||||
-rw-r--r-- | contrib/python/freezegun/py3/freezegun/config.py | 2 | ||||
-rw-r--r-- | contrib/python/freezegun/py3/ya.make | 2 |
6 files changed, 33 insertions, 11 deletions
diff --git a/contrib/python/freezegun/py3/.dist-info/METADATA b/contrib/python/freezegun/py3/.dist-info/METADATA index 30bf3daa62..0978a40fcb 100644 --- a/contrib/python/freezegun/py3/.dist-info/METADATA +++ b/contrib/python/freezegun/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: freezegun -Version: 1.2.2 +Version: 1.3.1 Summary: Let your Python tests travel through time Home-page: https://github.com/spulec/freezegun Author: Steve Pulec @@ -15,12 +15,15 @@ Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy -Requires-Python: >=3.6 +Requires-Python: >=3.7 License-File: LICENSE License-File: AUTHORS.rst -Requires-Dist: python-dateutil (>=2.7) +Requires-Dist: python-dateutil >=2.7 FreezeGun: Let your Python tests travel through time ==================================================== diff --git a/contrib/python/freezegun/py3/AUTHORS.rst b/contrib/python/freezegun/py3/AUTHORS.rst index 41c446b9bd..62e4962735 100644 --- a/contrib/python/freezegun/py3/AUTHORS.rst +++ b/contrib/python/freezegun/py3/AUTHORS.rst @@ -20,3 +20,4 @@ Patches and Suggestions - `Lukasz Balcerzak <https://github.com/lukaszb>`_ - `Hannes Ljungberg <hannes@5monkeys.se>`_ - `staticdev <staticdev-support@proton.me>`_ +- `Marcin Sulikowski <https://github.com/marcinsulikowski>`_ diff --git a/contrib/python/freezegun/py3/freezegun/__init__.py b/contrib/python/freezegun/py3/freezegun/__init__.py index 058940f124..003b2bd878 100644 --- a/contrib/python/freezegun/py3/freezegun/__init__.py +++ b/contrib/python/freezegun/py3/freezegun/__init__.py @@ -9,7 +9,7 @@ from .api import freeze_time from .config import configure __title__ = 'freezegun' -__version__ = '1.2.2' +__version__ = '1.3.1' __author__ = 'Steve Pulec' __license__ = 'Apache License 2.0' __copyright__ = 'Copyright 2012 Steve Pulec' diff --git a/contrib/python/freezegun/py3/freezegun/api.py b/contrib/python/freezegun/py3/freezegun/api.py index bcc83a6e08..f732ff8c24 100644 --- a/contrib/python/freezegun/py3/freezegun/api.py +++ b/contrib/python/freezegun/py3/freezegun/api.py @@ -1,5 +1,6 @@ from . import config from ._async import wrap_coroutine +import asyncio import copyreg import dateutil import datetime @@ -407,7 +408,7 @@ class FakeDatetime(real_datetime, FakeDate, metaclass=FakeDatetimeMeta): @classmethod def utcnow(cls): - result = cls._time_to_freeze() or real_datetime.utcnow() + result = cls._time_to_freeze() or real_datetime.now(datetime.timezone.utc) return datetime_to_fakedatetime(result) @staticmethod @@ -462,14 +463,14 @@ def _parse_time_to_freeze(time_to_freeze_str): :returns: a naive ``datetime.datetime`` object """ if time_to_freeze_str is None: - time_to_freeze_str = datetime.datetime.utcnow() + time_to_freeze_str = datetime.datetime.now(datetime.timezone.utc) if isinstance(time_to_freeze_str, datetime.datetime): time_to_freeze = time_to_freeze_str elif isinstance(time_to_freeze_str, datetime.date): time_to_freeze = datetime.datetime.combine(time_to_freeze_str, datetime.time()) elif isinstance(time_to_freeze_str, datetime.timedelta): - time_to_freeze = datetime.datetime.utcnow() + time_to_freeze_str + time_to_freeze = datetime.datetime.now(datetime.timezone.utc) + time_to_freeze_str else: time_to_freeze = parser.parse(time_to_freeze_str) @@ -619,7 +620,7 @@ class _freeze_time: continue seen.add(attr) - if not callable(attr_value) or inspect.isclass(attr_value): + if not callable(attr_value) or inspect.isclass(attr_value) or isinstance(attr_value, staticmethod): continue try: @@ -726,6 +727,21 @@ class _freeze_time: setattr(module, attribute_name, fake) add_change((module, attribute_name, attribute_value)) + # To avoid breaking `asyncio.sleep()`, let asyncio event loops see real + # monotonic time even though we've just frozen `time.monotonic()` which + # is normally used there. If we didn't do this, `await asyncio.sleep()` + # would be hanging forever breaking many tests that use `freeze_time`. + # + # Note that we cannot statically tell the class of asyncio event loops + # because it is not officially documented and can actually be changed + # at run time using `asyncio.set_event_loop_policy`. That's why we check + # the type by creating a loop here and destroying it immediately. + event_loop = asyncio.new_event_loop() + event_loop.close() + EventLoopClass = type(event_loop) + add_change((EventLoopClass, "time", EventLoopClass.time)) + EventLoopClass.time = lambda self: real_monotonic() + return freeze_factory def stop(self): @@ -739,8 +755,8 @@ class _freeze_time: datetime.date = real_date copyreg.dispatch_table.pop(real_datetime) copyreg.dispatch_table.pop(real_date) - for module, module_attribute, original_value in self.undo_changes: - setattr(module, module_attribute, original_value) + for module_or_object, attribute, original_value in self.undo_changes: + setattr(module_or_object, attribute, original_value) self.undo_changes = [] # Restore modules loaded after start() diff --git a/contrib/python/freezegun/py3/freezegun/config.py b/contrib/python/freezegun/py3/freezegun/config.py index 0f669d734a..cbbd8ae6a4 100644 --- a/contrib/python/freezegun/py3/freezegun/config.py +++ b/contrib/python/freezegun/py3/freezegun/config.py @@ -7,11 +7,13 @@ DEFAULT_IGNORE_LIST = [ 'django.utils.six.moves', 'google.gax', 'threading', + 'multiprocessing', 'Queue', 'selenium', '_pytest.terminal.', '_pytest.runner.', 'gi', + 'prompt_toolkit', ] diff --git a/contrib/python/freezegun/py3/ya.make b/contrib/python/freezegun/py3/ya.make index 2d9702eb00..4c2d15c637 100644 --- a/contrib/python/freezegun/py3/ya.make +++ b/contrib/python/freezegun/py3/ya.make @@ -4,7 +4,7 @@ PY3_LIBRARY() PROVIDES(freezegun) -VERSION(1.2.2) +VERSION(1.3.1) LICENSE(Apache-2.0) |