Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-freezegun for openSUSE:Factory checked in at 2021-02-01 13:26:53 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-freezegun (Old) and /work/SRC/openSUSE:Factory/.python-freezegun.new.28504 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-freezegun" Mon Feb 1 13:26:53 2021 rev:12 rq:867591 version:1.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-freezegun/python-freezegun.changes 2020-10-23 12:19:14.152555706 +0200 +++ /work/SRC/openSUSE:Factory/.python-freezegun.new.28504/python-freezegun.changes 2021-02-01 13:28:36.754141273 +0100 @@ -1,0 +2,8 @@ +Thu Jan 28 22:52:22 UTC 2021 - Dirk M��ller <dmueller@suse.com> + +- update to 1.1.0: + * Add support for `time.monotonic` (and `���_ns`) + * Allow to configure default ignore list, and also to just extend the default + * Fixed when accessing from thread after stop() + +------------------------------------------------------------------- Old: ---- freezegun-1.0.0.tar.gz New: ---- freezegun-1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-freezegun.spec ++++++ --- /var/tmp/diff_new_pack.A9mK8x/_old 2021-02-01 13:28:37.350142200 +0100 +++ /var/tmp/diff_new_pack.A9mK8x/_new 2021-02-01 13:28:37.354142206 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-freezegun # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without python2 Name: python-freezegun -Version: 1.0.0 +Version: 1.1.0 Release: 0 Summary: Mock time date for Python License: Apache-2.0 ++++++ freezegun-1.0.0.tar.gz -> freezegun-1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/AUTHORS.rst new/freezegun-1.1.0/AUTHORS.rst --- old/freezegun-1.0.0/AUTHORS.rst 2020-09-05 02:51:58.000000000 +0200 +++ new/freezegun-1.1.0/AUTHORS.rst 2021-01-20 08:25:47.000000000 +0100 @@ -16,3 +16,5 @@ - `James Lu <github.com/CrazyPython>`_ - `Dan Elkis <github.com/rinslow>`_ - `Bastien Vallet <github.com/djailla>`_ +- `Julian Mehnle <github.com/jmehnle>`_ +- `Lukasz Balcerzak <https://github.com/lukaszb>`_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/CHANGELOG new/freezegun-1.1.0/CHANGELOG --- old/freezegun-1.0.0/CHANGELOG 2020-09-05 18:24:04.000000000 +0200 +++ new/freezegun-1.1.0/CHANGELOG 2021-01-20 08:29:44.000000000 +0100 @@ -1,8 +1,15 @@ Freezegun Changelog =================== -Latest ------- +1.1.0 +----- + +* Add support for `time.monotonic` (and `���_ns`) + +* Allow to configure default ignore list, and also to just extend the default + +* Fixed when accessing from thread after stop() + 1.0.0 ------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/PKG-INFO new/freezegun-1.1.0/PKG-INFO --- old/freezegun-1.0.0/PKG-INFO 2020-09-05 18:30:28.900934200 +0200 +++ new/freezegun-1.1.0/PKG-INFO 2021-01-20 08:45:05.444875000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: freezegun -Version: 1.0.0 +Version: 1.1.0 Summary: Let your Python tests travel through time Home-page: https://github.com/spulec/freezegun Author: Steve Pulec @@ -21,7 +21,7 @@ Usage ----- - Once the decorator or context manager have been invoked, all calls to datetime.datetime.now(), datetime.datetime.utcnow(), datetime.date.today(), time.time(), time.localtime(), time.gmtime(), and time.strftime() will return the time that has been frozen. + Once the decorator or context manager have been invoked, all calls to datetime.datetime.now(), datetime.datetime.utcnow(), datetime.date.today(), time.time(), time.localtime(), time.gmtime(), and time.strftime() will return the time that has been frozen. time.monotonic() will also be frozen, but as usual it makes no guarantees about its absolute value, only its changes over time. Decorator ~~~~~~~~~ @@ -32,6 +32,7 @@ import datetime import unittest + # Freeze time for a pytest style test: @freeze_time("2012-01-14") def test(): @@ -181,7 +182,7 @@ .. code-block:: python - def test_manual_increment(): + def test_manual_tick(): initial_datetime = datetime.datetime(year=1, month=7, day=12, hour=15, minute=6, second=3) with freeze_time(initial_datetime) as frozen_datetime: @@ -195,6 +196,18 @@ initial_datetime += datetime.timedelta(seconds=10) assert frozen_datetime() == initial_datetime + .. code-block:: python + + def test_monotonic_manual_tick(): + initial_datetime = datetime.datetime(year=1, month=7, day=12, + hour=15, minute=6, second=3) + with freeze_time(initial_datetime) as frozen_datetime: + monotonic_t0 = time.monotonic() + frozen_datetime.tick(1.0) + monotonic_t1 = time.monotonic() + assert monotonic_t1 == monotonic_t0 + 1.0 + + Moving time to specify datetime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -260,6 +273,58 @@ $ sudo apt-get install python-freezegun + + Ignore packages + --------------- + + Sometimes it's desired to ignore FreezeGun behaviour for particular packages (i.e. libraries). + It's possible to ignore them for a single invocation: + + + .. code-block:: python + + from freezegun import freeze_time + + with freeze_time('2020-10-06', ignore=['threading']): + # ... + + + By default FreezeGun ignores following packages: + + .. code-block:: python + + [ + 'nose.plugins', + 'six.moves', + 'django.utils.six.moves', + 'google.gax', + 'threading', + 'Queue', + 'selenium', + '_pytest.terminal.', + '_pytest.runner.', + 'gi', + ] + + + It's possible to set your own default ignore list: + + .. code-block:: python + + import freezegun + + freezegun.configure(default_ignore_list=['threading', 'tensorflow']) + + + Please note this will override default ignore list. If you want to extend existing defaults + please use: + + .. code-block:: python + + import freezegun + + freezegun.configure(extend_ignore_list=['tensorflow']) + Platform: UNKNOWN Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Python :: 3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/README.rst new/freezegun-1.1.0/README.rst --- old/freezegun-1.0.0/README.rst 2020-09-05 02:51:58.000000000 +0200 +++ new/freezegun-1.1.0/README.rst 2021-01-20 08:25:47.000000000 +0100 @@ -13,7 +13,7 @@ Usage ----- -Once the decorator or context manager have been invoked, all calls to datetime.datetime.now(), datetime.datetime.utcnow(), datetime.date.today(), time.time(), time.localtime(), time.gmtime(), and time.strftime() will return the time that has been frozen. +Once the decorator or context manager have been invoked, all calls to datetime.datetime.now(), datetime.datetime.utcnow(), datetime.date.today(), time.time(), time.localtime(), time.gmtime(), and time.strftime() will return the time that has been frozen. time.monotonic() will also be frozen, but as usual it makes no guarantees about its absolute value, only its changes over time. Decorator ~~~~~~~~~ @@ -24,6 +24,7 @@ import datetime import unittest + # Freeze time for a pytest style test: @freeze_time("2012-01-14") def test(): @@ -173,7 +174,7 @@ .. code-block:: python - def test_manual_increment(): + def test_manual_tick(): initial_datetime = datetime.datetime(year=1, month=7, day=12, hour=15, minute=6, second=3) with freeze_time(initial_datetime) as frozen_datetime: @@ -187,6 +188,18 @@ initial_datetime += datetime.timedelta(seconds=10) assert frozen_datetime() == initial_datetime +.. code-block:: python + + def test_monotonic_manual_tick(): + initial_datetime = datetime.datetime(year=1, month=7, day=12, + hour=15, minute=6, second=3) + with freeze_time(initial_datetime) as frozen_datetime: + monotonic_t0 = time.monotonic() + frozen_datetime.tick(1.0) + monotonic_t1 = time.monotonic() + assert monotonic_t1 == monotonic_t0 + 1.0 + + Moving time to specify datetime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -251,3 +264,55 @@ .. code-block:: bash $ sudo apt-get install python-freezegun + + +Ignore packages +--------------- + +Sometimes it's desired to ignore FreezeGun behaviour for particular packages (i.e. libraries). +It's possible to ignore them for a single invocation: + + +.. code-block:: python + + from freezegun import freeze_time + + with freeze_time('2020-10-06', ignore=['threading']): + # ... + + +By default FreezeGun ignores following packages: + +.. code-block:: python + + [ + 'nose.plugins', + 'six.moves', + 'django.utils.six.moves', + 'google.gax', + 'threading', + 'Queue', + 'selenium', + '_pytest.terminal.', + '_pytest.runner.', + 'gi', + ] + + +It's possible to set your own default ignore list: + +.. code-block:: python + + import freezegun + + freezegun.configure(default_ignore_list=['threading', 'tensorflow']) + + +Please note this will override default ignore list. If you want to extend existing defaults +please use: + +.. code-block:: python + + import freezegun + + freezegun.configure(extend_ignore_list=['tensorflow']) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/freezegun/__init__.py new/freezegun-1.1.0/freezegun/__init__.py --- old/freezegun-1.0.0/freezegun/__init__.py 2020-09-05 18:24:31.000000000 +0200 +++ new/freezegun-1.1.0/freezegun/__init__.py 2021-01-20 08:30:17.000000000 +0100 @@ -7,12 +7,13 @@ """ from .api import freeze_time +from .config import configure __title__ = 'freezegun' -__version__ = '1.0.0' +__version__ = '1.1.0' __author__ = 'Steve Pulec' __license__ = 'Apache License 2.0' __copyright__ = 'Copyright 2012 Steve Pulec' -__all__ = ["freeze_time"] +__all__ = ["freeze_time", "configure"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/freezegun/api.py new/freezegun-1.1.0/freezegun/api.py --- old/freezegun-1.0.0/freezegun/api.py 2020-09-05 02:51:58.000000000 +0200 +++ new/freezegun-1.1.0/freezegun/api.py 2021-01-20 08:25:47.000000000 +0100 @@ -1,3 +1,4 @@ +from . import config import dateutil import datetime import functools @@ -22,21 +23,27 @@ MayaDT = None _TIME_NS_PRESENT = hasattr(time, 'time_ns') +_MONOTONIC_NS_PRESENT = hasattr(time, 'monotonic_ns') _EPOCH = datetime.datetime(1970, 1, 1) _EPOCHTZ = datetime.datetime(1970, 1, 1, tzinfo=dateutil.tz.UTC) real_time = time.time real_localtime = time.localtime real_gmtime = time.gmtime +real_monotonic = time.monotonic 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] +real_date_objects = [real_time, real_localtime, real_gmtime, real_monotonic, real_strftime, real_date, real_datetime] if _TIME_NS_PRESENT: real_time_ns = time.time_ns real_date_objects.append(real_time_ns) +if _MONOTONIC_NS_PRESENT: + real_monotonic_ns = time.monotonic_ns + real_date_objects.append(real_monotonic_ns) + _real_time_object_ids = {id(obj) for obj in real_date_objects} # time.clock is deprecated and was removed in Python 3.8 @@ -160,6 +167,10 @@ if not call_stack_inspection_limit: return False + # Means stop() has already been called, so we can now return the real time + if not ignore_lists: + return True + if not ignore_lists[-1]: return False @@ -211,6 +222,23 @@ return get_current_time().timetuple() +def fake_monotonic(): + if _should_use_real_time(): + return real_monotonic() + current_time = get_current_time() + return calendar.timegm(current_time.timetuple()) + current_time.microsecond / 1000000.0 + +if _MONOTONIC_NS_PRESENT: + def fake_monotonic_ns(): + if _should_use_real_time(): + return real_monotonic_ns() + current_time = get_current_time() + return ( + calendar.timegm(current_time.timetuple()) * 1000000 + + current_time.microsecond + ) * 1000 + + def fake_strftime(format, time_to_format=None): if time_to_format is None: if not _should_use_real_time(): @@ -609,6 +637,7 @@ datetime.date = FakeDate time.time = fake_time + time.monotonic = fake_monotonic time.localtime = fake_localtime time.gmtime = fake_gmtime time.strftime = fake_strftime @@ -626,6 +655,7 @@ ('real_datetime', real_datetime, FakeDatetime), ('real_gmtime', real_gmtime, fake_gmtime), ('real_localtime', real_localtime, fake_localtime), + ('real_monotonic', real_monotonic, fake_monotonic), ('real_strftime', real_strftime, fake_strftime), ('real_time', real_time, fake_time), ] @@ -634,6 +664,10 @@ time.time_ns = fake_time_ns to_patch.append(('real_time_ns', real_time_ns, fake_time_ns)) + if _MONOTONIC_NS_PRESENT: + time.monotonic_ns = fake_monotonic_ns + to_patch.append(('real_monotonic_ns', real_monotonic_ns, fake_monotonic_ns)) + if real_clock is not None: # time.clock is deprecated and was removed in Python 3.8 time.clock = fake_clock @@ -710,6 +744,7 @@ setattr(module, module_attribute, real) time.time = real_time + time.monotonic = real_monotonic time.gmtime = real_gmtime time.localtime = real_localtime time.strftime = real_strftime @@ -718,6 +753,9 @@ if _TIME_NS_PRESENT: time.time_ns = real_time_ns + if _MONOTONIC_NS_PRESENT: + time.monotonic_ns = real_monotonic_ns + if uuid_generate_time_attr: setattr(uuid, uuid_generate_time_attr, real_uuid_generate_time) uuid._UuidCreate = real_uuid_create @@ -776,19 +814,18 @@ if ignore is None: ignore = [] ignore = ignore[:] - ignore.extend(['nose.plugins', - 'six.moves', - 'django.utils.six.moves', - 'google.gax', - 'threading', - 'Queue', - 'selenium', - '_pytest.terminal.', - '_pytest.runner.', - 'gi', - ]) + if config.settings.default_ignore_list: + ignore.extend(config.settings.default_ignore_list) - return _freeze_time(time_to_freeze, tz_offset, ignore, tick, as_arg, as_kwarg, auto_tick_seconds) + return _freeze_time( + time_to_freeze_str=time_to_freeze, + tz_offset=tz_offset, + ignore=ignore, + tick=tick, + as_arg=as_arg, + as_kwarg=as_kwarg, + auto_tick_seconds=auto_tick_seconds, + ) # Setup adapters for sqlite diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/freezegun/config.py new/freezegun-1.1.0/freezegun/config.py --- old/freezegun-1.0.0/freezegun/config.py 1970-01-01 01:00:00.000000000 +0100 +++ new/freezegun-1.1.0/freezegun/config.py 2021-01-20 08:25:47.000000000 +0100 @@ -0,0 +1,40 @@ + + +DEFAULT_IGNORE_LIST = [ + 'nose.plugins', + 'six.moves', + 'django.utils.six.moves', + 'google.gax', + 'threading', + 'Queue', + 'selenium', + '_pytest.terminal.', + '_pytest.runner.', + 'gi', +] + + +class Settings: + def __init__(self, default_ignore_list=None): + self.default_ignore_list = default_ignore_list or DEFAULT_IGNORE_LIST[:] + + +settings = Settings() + + +class ConfigurationError(Exception): + pass + + +def configure(default_ignore_list=None, extend_ignore_list=None): + if default_ignore_list is not None and extend_ignore_list is not None: + raise ConfigurationError("Either default_ignore_list or extend_ignore_list might be given, not both") + if default_ignore_list: + settings.default_ignore_list = default_ignore_list + if extend_ignore_list: + settings.default_ignore_list = [*settings.default_ignore_list, *extend_ignore_list] + + +def reset_config(): + global settings + settings = Settings() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/freezegun.egg-info/PKG-INFO new/freezegun-1.1.0/freezegun.egg-info/PKG-INFO --- old/freezegun-1.0.0/freezegun.egg-info/PKG-INFO 2020-09-05 18:30:28.000000000 +0200 +++ new/freezegun-1.1.0/freezegun.egg-info/PKG-INFO 2021-01-20 08:45:05.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: freezegun -Version: 1.0.0 +Version: 1.1.0 Summary: Let your Python tests travel through time Home-page: https://github.com/spulec/freezegun Author: Steve Pulec @@ -21,7 +21,7 @@ Usage ----- - Once the decorator or context manager have been invoked, all calls to datetime.datetime.now(), datetime.datetime.utcnow(), datetime.date.today(), time.time(), time.localtime(), time.gmtime(), and time.strftime() will return the time that has been frozen. + Once the decorator or context manager have been invoked, all calls to datetime.datetime.now(), datetime.datetime.utcnow(), datetime.date.today(), time.time(), time.localtime(), time.gmtime(), and time.strftime() will return the time that has been frozen. time.monotonic() will also be frozen, but as usual it makes no guarantees about its absolute value, only its changes over time. Decorator ~~~~~~~~~ @@ -32,6 +32,7 @@ import datetime import unittest + # Freeze time for a pytest style test: @freeze_time("2012-01-14") def test(): @@ -181,7 +182,7 @@ .. code-block:: python - def test_manual_increment(): + def test_manual_tick(): initial_datetime = datetime.datetime(year=1, month=7, day=12, hour=15, minute=6, second=3) with freeze_time(initial_datetime) as frozen_datetime: @@ -195,6 +196,18 @@ initial_datetime += datetime.timedelta(seconds=10) assert frozen_datetime() == initial_datetime + .. code-block:: python + + def test_monotonic_manual_tick(): + initial_datetime = datetime.datetime(year=1, month=7, day=12, + hour=15, minute=6, second=3) + with freeze_time(initial_datetime) as frozen_datetime: + monotonic_t0 = time.monotonic() + frozen_datetime.tick(1.0) + monotonic_t1 = time.monotonic() + assert monotonic_t1 == monotonic_t0 + 1.0 + + Moving time to specify datetime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -260,6 +273,58 @@ $ sudo apt-get install python-freezegun + + Ignore packages + --------------- + + Sometimes it's desired to ignore FreezeGun behaviour for particular packages (i.e. libraries). + It's possible to ignore them for a single invocation: + + + .. code-block:: python + + from freezegun import freeze_time + + with freeze_time('2020-10-06', ignore=['threading']): + # ... + + + By default FreezeGun ignores following packages: + + .. code-block:: python + + [ + 'nose.plugins', + 'six.moves', + 'django.utils.six.moves', + 'google.gax', + 'threading', + 'Queue', + 'selenium', + '_pytest.terminal.', + '_pytest.runner.', + 'gi', + ] + + + It's possible to set your own default ignore list: + + .. code-block:: python + + import freezegun + + freezegun.configure(default_ignore_list=['threading', 'tensorflow']) + + + Please note this will override default ignore list. If you want to extend existing defaults + please use: + + .. code-block:: python + + import freezegun + + freezegun.configure(extend_ignore_list=['tensorflow']) + Platform: UNKNOWN Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Python :: 3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/freezegun.egg-info/SOURCES.txt new/freezegun-1.1.0/freezegun.egg-info/SOURCES.txt --- old/freezegun-1.0.0/freezegun.egg-info/SOURCES.txt 2020-09-05 18:30:28.000000000 +0200 +++ new/freezegun-1.1.0/freezegun.egg-info/SOURCES.txt 2021-01-20 08:45:05.000000000 +0100 @@ -10,6 +10,7 @@ freezegun/_async.py freezegun/_async_coroutine.py freezegun/api.py +freezegun/config.py freezegun.egg-info/PKG-INFO freezegun.egg-info/SOURCES.txt freezegun.egg-info/dependency_links.txt @@ -20,6 +21,7 @@ tests/fake_module.py tests/test_asyncio.py tests/test_class_import.py +tests/test_configure.py tests/test_datetimes.py tests/test_errors.py tests/test_import_alias.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/setup.py new/freezegun-1.1.0/setup.py --- old/freezegun-1.0.0/setup.py 2020-09-05 18:24:08.000000000 +0200 +++ new/freezegun-1.1.0/setup.py 2021-01-20 08:44:45.000000000 +0100 @@ -1,13 +1,24 @@ #!/usr/bin/env python +import os +import re from setuptools import setup with open('README.rst') as f: readme = f.read() + +def read_version(): + with open(os.path.join('freezegun', '__init__.py')) as f: + m = re.search(r'''__version__\s*=\s*['"]([^'"]*)['"]''', f.read()) + if m: + return m.group(1) + raise ValueError("couldn't find version") + + setup( name='freezegun', - version='1.0.0', + version=read_version(), description='Let your Python tests travel through time', long_description=readme, author='Steve Pulec', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/tests/test_configure.py new/freezegun-1.1.0/tests/test_configure.py --- old/freezegun-1.0.0/tests/test_configure.py 1970-01-01 01:00:00.000000000 +0100 +++ new/freezegun-1.1.0/tests/test_configure.py 2021-01-20 08:25:47.000000000 +0100 @@ -0,0 +1,65 @@ +from unittest import mock +import freezegun +import freezegun.config + + +def setup_function(): + freezegun.config.reset_config() + + +def teardown_function(): + freezegun.config.reset_config() + + +def test_default_ignore_list_is_overridden(): + freezegun.configure(default_ignore_list=['threading', 'tensorflow']) + + with mock.patch("freezegun.api._freeze_time.__init__", return_value=None) as _freeze_time_init_mock: + + freezegun.freeze_time("2020-10-06") + + expected_ignore_list = [ + 'threading', + 'tensorflow', + ] + + _freeze_time_init_mock.assert_called_once_with( + time_to_freeze_str="2020-10-06", + tz_offset=0, + ignore=expected_ignore_list, + tick=False, + as_arg=False, + as_kwarg='', + auto_tick_seconds=0, + ) + +def test_extend_default_ignore_list(): + freezegun.configure(extend_ignore_list=['tensorflow']) + + with mock.patch("freezegun.api._freeze_time.__init__", return_value=None) as _freeze_time_init_mock: + + freezegun.freeze_time("2020-10-06") + + expected_ignore_list = [ + 'nose.plugins', + 'six.moves', + 'django.utils.six.moves', + 'google.gax', + 'threading', + 'Queue', + 'selenium', + '_pytest.terminal.', + '_pytest.runner.', + 'gi', + 'tensorflow', + ] + + _freeze_time_init_mock.assert_called_once_with( + time_to_freeze_str="2020-10-06", + tz_offset=0, + ignore=expected_ignore_list, + tick=False, + as_arg=False, + as_kwarg='', + auto_tick_seconds=0, + ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/tests/test_datetimes.py new/freezegun-1.1.0/tests/test_datetimes.py --- old/freezegun-1.0.0/tests/test_datetimes.py 2020-09-05 02:51:58.000000000 +0200 +++ new/freezegun-1.1.0/tests/test_datetimes.py 2021-01-20 08:25:47.000000000 +0100 @@ -21,6 +21,7 @@ # time.clock was removed in Python 3.8 HAS_CLOCK = hasattr(time, 'clock') HAS_TIME_NS = hasattr(time, 'time_ns') +HAS_MONOTONIC_NS = hasattr(time, 'monotonic_ns') class temp_locale(object): """Temporarily change the locale.""" @@ -57,12 +58,14 @@ freezer.start() assert time.time() == expected_timestamp + assert time.monotonic() >= 0.0 assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) assert datetime.datetime.utcnow() == datetime.datetime(2012, 1, 14) assert datetime.date.today() == datetime.date(2012, 1, 14) assert datetime.datetime.now().today() == datetime.datetime(2012, 1, 14) freezer.stop() assert time.time() != expected_timestamp + assert time.monotonic() >= 0.0 assert datetime.datetime.now() != datetime.datetime(2012, 1, 14) assert datetime.datetime.utcnow() != datetime.datetime(2012, 1, 14) freezer = freeze_time("2012-01-10 13:52:01") @@ -113,6 +116,7 @@ assert datetime.datetime.now() == datetime.datetime(1970, 1, 1) assert datetime.datetime.utcnow() == datetime.datetime(1970, 1, 1) assert time.time() == 0.0 + assert time.monotonic() >= 0.0 freezer.stop() @@ -125,6 +129,7 @@ assert datetime.datetime.now() == datetime.datetime(1969, 12, 31, 20) assert datetime.datetime.utcnow() == datetime.datetime(1970, 1, 1) assert time.time() == 0.0 + assert time.monotonic() >= 0 freezer.stop() @@ -197,6 +202,29 @@ assert False, "Bad values should raise a ValueError" +def test_time_monotonic(): + initial_datetime = datetime.datetime(year=1, month=7, day=12, + hour=15, minute=6, second=3) + with freeze_time(initial_datetime) as frozen_datetime: + monotonic_t0 = time.monotonic() + if HAS_MONOTONIC_NS: + monotonic_ns_t0 = time.monotonic_ns() + + frozen_datetime.tick() + monotonic_t1 = time.monotonic() + assert monotonic_t1 == monotonic_t0 + 1.0 + if HAS_MONOTONIC_NS: + monotonic_ns_t1 = time.monotonic_ns() + assert monotonic_ns_t1 == monotonic_ns_t0 + 1000000000 + + frozen_datetime.tick(10) + monotonic_t11 = time.monotonic() + assert monotonic_t11 == monotonic_t1 + 10.0 + if HAS_MONOTONIC_NS: + monotonic_ns_t11 = time.monotonic_ns() + assert monotonic_ns_t11 == monotonic_ns_t1 + 10000000000 + + def test_time_gmtime(): with freeze_time('2012-01-14 03:21:34'): time_struct = time.gmtime() @@ -649,6 +677,20 @@ assert time() == second +def test_monotonic_with_nested(): + from time import monotonic + + with freeze_time('2015-01-01') as frozen_datetime_1: + initial_monotonic_1 = time.monotonic() + with freeze_time('2015-12-25') as frozen_datetime_2: + initial_monotonic_2 = time.monotonic() + frozen_datetime_2.tick() + assert time.monotonic() == initial_monotonic_2 + 1 + assert time.monotonic() == initial_monotonic_1 + frozen_datetime_1.tick() + assert time.monotonic() == initial_monotonic_1 + 1 + + def test_should_use_real_time(): frozen = datetime.datetime(2015, 3, 5) expected_frozen = 1425513600.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/freezegun-1.0.0/tests/test_ticking.py new/freezegun-1.1.0/tests/test_ticking.py --- old/freezegun-1.0.0/tests/test_ticking.py 2020-09-05 02:51:58.000000000 +0200 +++ new/freezegun-1.1.0/tests/test_ticking.py 2021-01-20 08:25:47.000000000 +0100 @@ -62,6 +62,14 @@ assert time.time() > 1326585599.0 +@utils.cpython_only +def test_ticking_monotonic(): + with freeze_time("Jan 14th, 2012, 23:59:59", tick=True): + initial_monotonic = time.monotonic() + time.sleep(0.001) # Deal with potential clock resolution problems + assert time.monotonic() > initial_monotonic + + @mock.patch('freezegun.api._is_cpython', False) def test_pypy_compat(): try: