Hello community,
here is the log from the commit of package python-freezegun for
openSUSE:Factory checked in at 2019-01-28 20:46:06
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-freezegun (Old)
and /work/SRC/openSUSE:Factory/.python-freezegun.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-freezegun"
Mon Jan 28 20:46:06 2019 rev:5 rq:666515 version:0.3.11
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-freezegun/python-freezegun.changes
2018-09-10 12:29:48.838837569 +0200
+++
/work/SRC/openSUSE:Factory/.python-freezegun.new.28833/python-freezegun.changes
2019-01-28 20:46:09.438049609 +0100
@@ -1,0 +2,15 @@
+Thu Jan 10 14:29:14 CET 2019 - [email protected]
+
+- Update to 0.3.11:
+ * Performance improvements
+ * Fix nesting time.time
+ * Add nanosecond property
+- Remove nose dependency by adding denose.patch
+- Remove _u_p37_tests.patch, which is superseeded by new release.
+
+-------------------------------------------------------------------
+Tue Dec 4 12:48:13 UTC 2018 - Matej Cepl <[email protected]>
+
+- Remove superfluous devel dependency for noarch package
+
+-------------------------------------------------------------------
Old:
----
_u_p37_tests.patch
freezegun-0.3.10.tar.gz
New:
----
denose.patch
freezegun-0.3.11.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-freezegun.spec ++++++
--- /var/tmp/diff_new_pack.3JpEPd/_old 2019-01-28 20:46:09.830049196 +0100
+++ /var/tmp/diff_new_pack.3JpEPd/_new 2019-01-28 20:46:09.830049196 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-freezegun
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,24 +12,23 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%bcond_without tests
Name: python-freezegun
-Version: 0.3.10
+Version: 0.3.11
Release: 0
Summary: Mock time date for Python
License: Apache-2.0
Group: Development/Languages/Python
URL: https://github.com/spulec/freezegun
Source:
https://files.pythonhosted.org/packages/source/f/freezegun/freezegun-%{version}.tar.gz
-Patch0: _u_p37_tests.patch
-# https://github.com/spulec/freezegun/issues/259
-Patch1: remove_dependency_on_mock.patch
-BuildRequires: %{python_module devel}
+# gh#spulec/freezegun#259
+Patch0: remove_dependency_on_mock.patch
+# gh#spulec/freezegun#280 Removal of nose dependency
+Patch1: denose.patch
BuildRequires: %{python_module python-dateutil > 2.0}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module six}
@@ -38,10 +37,7 @@
Requires: python-python-dateutil > 2.0
Requires: python-six
BuildArch: noarch
-%if %{with tests}
-BuildRequires: %{python_module nose}
BuildRequires: python2-mock
-%endif
%python_subpackages
%description
@@ -59,10 +55,8 @@
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
-%if %{with tests}
%check
-%python_expand nosetests-%{$python_bin_suffix}
-%endif
+%python_exec -munittest discover -v
%files %{python_files}
%license LICENSE
++++++ denose.patch ++++++
++++ 1150 lines (skipped)
++++++ freezegun-0.3.10.tar.gz -> freezegun-0.3.11.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/AUTHORS.rst
new/freezegun-0.3.11/AUTHORS.rst
--- old/freezegun-0.3.10/AUTHORS.rst 2018-03-06 02:15:53.000000000 +0100
+++ new/freezegun-0.3.11/AUTHORS.rst 2018-10-15 04:31:36.000000000 +0200
@@ -14,3 +14,4 @@
- `Adam Johnson <https://github.com/adamchainz>`_
- `Alex Ehlke <https://github.com/aehlke>`_
- `James Lu <github.com/CrazyPython>`_
+- `Dan Elkis <github.com/rinslow>`_
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/CHANGELOG
new/freezegun-0.3.11/CHANGELOG
--- old/freezegun-0.3.10/CHANGELOG 2018-03-06 03:53:53.000000000 +0100
+++ new/freezegun-0.3.11/CHANGELOG 2018-10-15 05:05:22.000000000 +0200
@@ -4,12 +4,18 @@
Latest
------
+0.3.11
+------
+
+* Performance improvements
+* Fix nesting time.time
+* Add nanosecond property
+
0.3.10
------
* Performance improvements
* Coroutine support
-*
0.3.9
-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/PKG-INFO
new/freezegun-0.3.11/PKG-INFO
--- old/freezegun-0.3.10/PKG-INFO 2018-03-06 03:54:52.000000000 +0100
+++ new/freezegun-0.3.11/PKG-INFO 2018-10-15 05:09:26.000000000 +0200
@@ -1,19 +1,241 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: freezegun
-Version: 0.3.10
+Version: 0.3.11
Summary: Let your Python tests travel through time
Home-page: https://github.com/spulec/freezegun
Author: Steve Pulec
Author-email: [email protected]
License: Apache 2.0
Description-Content-Type: UNKNOWN
-Description: UNKNOWN
+Description: FreezeGun: Let your Python tests travel through time
+ ====================================================
+
+
+ .. image::
https://secure.travis-ci.org/spulec/freezegun.svg?branch=master
+ :target: https://travis-ci.org/spulec/freezegun
+ .. image::
https://coveralls.io/repos/spulec/freezegun/badge.svg?branch=master
+ :target: https://coveralls.io/r/spulec/freezegun
+
+ FreezeGun is a library that allows your Python tests to travel through
time by mocking the datetime module.
+
+ 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.
+
+ Decorator
+ ~~~~~~~~~
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+ import datetime
+ import unittest
+
+
+ @freeze_time("2012-01-14")
+ def test():
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
14)
+
+ # Or a unittest TestCase - freezes for every test, from the start
of setUpClass to the end of tearDownClass
+
+ @freeze_time("1955-11-12")
+ class MyTests(unittest.TestCase):
+ def test_the_class(self):
+ assert datetime.datetime.now() == datetime.datetime(1955,
11, 12)
+
+ # Or any other class - freezes around each callable (may not work
in every case)
+
+ @freeze_time("2012-01-14")
+ class Tester(object):
+ def test_the_class(self):
+ assert datetime.datetime.now() == datetime.datetime(2012,
1, 14)
+
+ Context manager
+ ~~~~~~~~~~~~~~~
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+
+ def test():
+ assert datetime.datetime.now() != datetime.datetime(2012, 1,
14)
+ with freeze_time("2012-01-14"):
+ assert datetime.datetime.now() == datetime.datetime(2012,
1, 14)
+ assert datetime.datetime.now() != datetime.datetime(2012, 1,
14)
+
+ Raw use
+ ~~~~~~~
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+
+ freezer = freeze_time("2012-01-14 12:00:01")
+ freezer.start()
+ assert datetime.datetime.now() == datetime.datetime(2012, 1, 14,
12, 0, 1)
+ freezer.stop()
+
+ Timezones
+ ~~~~~~~~~
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+
+ @freeze_time("2012-01-14 03:21:34", tz_offset=-4)
+ def test():
+ assert datetime.datetime.utcnow() == datetime.datetime(2012,
1, 14, 3, 21, 34)
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
13, 23, 21, 34)
+
+ # datetime.date.today() uses local time
+ assert datetime.date.today() == datetime.date(2012, 1, 13)
+
+ @freeze_time("2012-01-14 03:21:34",
tz_offset=-datetime.timedelta(hours=3, minutes=30))
+ def test_timedelta_offset():
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
13, 23, 51, 34)
+
+ Nice inputs
+ ~~~~~~~~~~~
+
+ FreezeGun uses dateutil behind the scenes so you can have nice-looking
datetimes.
+
+ .. code-block:: python
+
+ @freeze_time("Jan 14th, 2012")
+ def test_nice_datetime():
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
14)
+
+ Function and generator objects
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ FreezeGun is able to handle function and generator objects.
+
+ .. code-block:: python
+
+ def test_lambda():
+ with freeze_time(lambda: datetime.datetime(2012, 1, 14)):
+ assert datetime.datetime.now() == datetime.datetime(2012,
1, 14)
+
+ def test_generator():
+ datetimes = (datetime.datetime(year, 1, 1) for year in
range(2010, 2012))
+
+ with freeze_time(datetimes):
+ assert datetime.datetime.now() == datetime.datetime(2010,
1, 1)
+
+ with freeze_time(datetimes):
+ assert datetime.datetime.now() == datetime.datetime(2011,
1, 1)
+
+ # The next call to freeze_time(datetimes) would raise a
StopIteration exception.
+
+ ``tick`` argument
+ ~~~~~~~~~~~~~~~~~
+
+ FreezeGun has an additional ``tick`` argument which will restart time
at the given
+ value, but then time will keep ticking. This is alternative to the
default
+ parameters which will keep time stopped.
+
+ .. code-block:: python
+
+ @freeze_time("Jan 14th, 2020", tick=True)
+ def test_nice_datetime():
+ assert datetime.datetime.now() > datetime.datetime(2020, 1, 14)
+
+ Manual ticks
+ ~~~~~~~~~~~~
+
+ FreezeGun allows for the time to be manually forwarded as well.
+
+ .. code-block:: python
+
+ def test_manual_increment():
+ initial_datetime = datetime.datetime(year=1, month=7, day=12,
+ hour=15, minute=6,
second=3)
+ with freeze_time(initial_datetime) as frozen_datetime:
+ assert frozen_datetime() == initial_datetime
+
+ frozen_datetime.tick()
+ initial_datetime += datetime.timedelta(seconds=1)
+ assert frozen_datetime() == initial_datetime
+
+ frozen_datetime.tick(delta=datetime.timedelta(seconds=10))
+ initial_datetime += datetime.timedelta(seconds=10)
+ assert frozen_datetime() == initial_datetime
+
+ Moving time to specify datetime
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ FreezeGun allows moving time to specific dates.
+
+ .. code-block:: python
+
+ def test_move_to():
+ initial_datetime = datetime.datetime(year=1, month=7, day=12,
+ hour=15, minute=6,
second=3)
+
+ other_datetime = datetime.datetime(year=2, month=8, day=13,
+ hour=14, minute=5,
second=0)
+ with freeze_time(initial_datetime) as frozen_datetime:
+ assert frozen_datetime() == initial_datetime
+
+ frozen_datetime.move_to(other_datetime)
+ assert frozen_datetime() == other_datetime
+
+ frozen_datetime.move_to(initial_datetime)
+ assert frozen_datetime() == initial_datetime
+
+
+ @freeze_time("2012-01-14", as_arg=True)
+ def test(frozen_time):
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
14)
+ frozen_time.move_to("2014-02-12")
+ assert datetime.datetime.now() == datetime.datetime(2014, 2,
12)
+
+ Parameter for ``move_to`` can be any valid ``freeze_time`` date
(string, date, datetime).
+
+
+ Default arguments
+ ~~~~~~~~~~~~~~~~~
+
+ Note that FreezeGun will not modify default arguments. The following
code will
+ print the current date. See `here
<http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments>`_
for why.
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+ import datetime as dt
+
+ def test(default=dt.date.today()):
+ print(default)
+
+ with freeze_time('2000-1-1'):
+ test()
+
+
+ Installation
+ ------------
+
+ To install FreezeGun, simply:
+
+ .. code-block:: bash
+
+ $ pip install freezegun
+
+ On Debian (Testing and Unstable) systems:
+
+ .. code-block:: bash
+
+ $ sudo apt-get install python-freezegun
+
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/README.rst
new/freezegun-0.3.11/README.rst
--- old/freezegun-0.3.10/README.rst 2018-03-06 03:30:32.000000000 +0100
+++ new/freezegun-0.3.11/README.rst 2018-10-15 04:31:36.000000000 +0200
@@ -7,7 +7,7 @@
.. image:: https://coveralls.io/repos/spulec/freezegun/badge.svg?branch=master
:target: https://coveralls.io/r/spulec/freezegun
-FreezeGun is a library that allows your python tests to travel through time by
mocking the datetime module.
+FreezeGun is a library that allows your Python tests to travel through time by
mocking the datetime module.
Usage
-----
@@ -42,7 +42,7 @@
def test_the_class(self):
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
-Context Manager
+Context manager
~~~~~~~~~~~~~~~
.. code-block:: python
@@ -135,7 +135,7 @@
Manual ticks
~~~~~~~~~~~~
-Freezegun allows for the time to be manually forwarded as well.
+FreezeGun allows for the time to be manually forwarded as well.
.. code-block:: python
@@ -156,7 +156,7 @@
Moving time to specify datetime
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Freezegun allows moving time to specific dates.
+FreezeGun allows moving time to specific dates.
.. code-block:: python
@@ -185,10 +185,10 @@
Parameter for ``move_to`` can be any valid ``freeze_time`` date (string, date,
datetime).
-Default Arguments
+Default arguments
~~~~~~~~~~~~~~~~~
-Note that Freezegun will not modify default arguments. The following code will
+Note that FreezeGun will not modify default arguments. The following code will
print the current date. See `here
<http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments>`_
for why.
.. code-block:: python
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/freezegun/__init__.py
new/freezegun-0.3.11/freezegun/__init__.py
--- old/freezegun-0.3.10/freezegun/__init__.py 2018-03-06 03:54:23.000000000
+0100
+++ new/freezegun-0.3.11/freezegun/__init__.py 2018-10-15 05:05:33.000000000
+0200
@@ -9,7 +9,7 @@
from .api import freeze_time
__title__ = 'freezegun'
-__version__ = '0.3.10'
+__version__ = '0.3.11'
__author__ = 'Steve Pulec'
__license__ = 'Apache License 2.0'
__copyright__ = 'Copyright 2012 Steve Pulec'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/freezegun/api.py
new/freezegun-0.3.11/freezegun/api.py
--- old/freezegun-0.3.10/freezegun/api.py 2018-03-06 03:31:33.000000000
+0100
+++ new/freezegun-0.3.11/freezegun/api.py 2018-10-15 04:58:23.000000000
+0200
@@ -1,7 +1,5 @@
import datetime
import functools
-import hashlib
-import inspect
import sys
import time
import uuid
@@ -11,24 +9,41 @@
import warnings
import types
import numbers
+import inspect
from dateutil import parser
from dateutil.tz import tzlocal
+
+try:
+ from maya import MayaDT
+except ImportError:
+ MayaDT = None
+
+
real_time = time.time
real_localtime = time.localtime
real_gmtime = time.gmtime
real_strftime = time.strftime
+real_clock = time.clock
real_date = datetime.date
real_datetime = datetime.datetime
real_date_objects = [real_time, real_localtime, real_gmtime, real_strftime,
real_date, real_datetime]
_real_time_object_ids = set(id(obj) for obj in real_date_objects)
+times_to_freeze = []
+tz_offsets = []
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
@@ -51,18 +66,7 @@
# keep a cache of module attributes otherwise freezegun will need to analyze
too many modules all the time
-# start with `None` as the sentinel value.
-# if `{}` (empty dict) was the sentinel value, there's a chance that
`setup_modules_cache()` will be called many times
-_GLOBAL_MODULES_CACHE = None
-
-
-def _get_global_modules_cache():
- global _GLOBAL_MODULES_CACHE
- # the first call to this function sets up the global module cache. it's
expected to be slower than consecutive calls
- if _GLOBAL_MODULES_CACHE is None:
- _GLOBAL_MODULES_CACHE = {}
- _setup_modules_cache()
- return _GLOBAL_MODULES_CACHE
+_GLOBAL_MODULES_CACHE = {}
def _get_module_attributes(module):
@@ -82,16 +86,7 @@
return result
-def _setup_modules_cache():
- for mod_name, module in list(sys.modules.items()):
- # ignore modules from freezegun
- if mod_name == __name__ or not mod_name or not module or not
hasattr(module, "__name__"):
- continue
- _setup_module_cache(module)
-
-
def _setup_module_cache(module):
- global _GLOBAL_MODULES_CACHE
date_attrs = []
all_module_attributes = _get_module_attributes(module)
for attribute_name, attribute_value in all_module_attributes:
@@ -101,17 +96,23 @@
def _get_module_attributes_hash(module):
- return '{0}-{1}'.format(id(module),
hashlib.md5(','.join(dir(module)).encode('utf-8')).hexdigest())
+ try:
+ module_dir = dir(module)
+ except TypeError:
+ module_dir = []
+ return '{0}-{1}'.format(id(module), hash(frozenset(module_dir)))
-def _get_cached_module_attributes(mod_name, module):
- global_modules_cache = _get_global_modules_cache()
- module_hash, cached_attrs = global_modules_cache.get(mod_name, ('0', []))
+def _get_cached_module_attributes(module):
+ module_hash, cached_attrs = _GLOBAL_MODULES_CACHE.get(module.__name__,
('0', []))
if _get_module_attributes_hash(module) == module_hash:
return cached_attrs
- else:
- _setup_module_cache(module)
- return _get_module_attributes(module)
+
+ # cache miss: update the cache and return the refreshed value
+ _setup_module_cache(module)
+ # return the newly cached value
+ module_hash, cached_attrs = _GLOBAL_MODULES_CACHE[module.__name__]
+ return cached_attrs
# Stolen from six
@@ -125,51 +126,108 @@
)
-class FakeTime(object):
+class BaseFakeTime(object):
+ call_stack_inspection_limit = 5
- def __init__(self, time_to_freeze, previous_time_function):
- self.time_to_freeze = time_to_freeze
+ def _should_use_real_time(self):
+ if not self.call_stack_inspection_limit:
+ return False
+
+ if not self.ignore:
+ return False
+
+ frame = inspect.currentframe().f_back.f_back
+
+ for _ in range(self.call_stack_inspection_limit):
+ module_name = frame.f_globals.get('__name__')
+ if module_name and module_name.startswith(self.ignore):
+ return True
+
+ frame = frame.f_back
+ if frame is None:
+ break
+
+ return False
+
+
+class FakeTime(BaseFakeTime):
+
+ def __init__(self, previous_time_function, ignore=None):
self.previous_time_function = previous_time_function
+ self.ignore = ignore
def __call__(self):
- current_time = self.time_to_freeze()
+ if self._should_use_real_time():
+ return real_time()
+ current_time = times_to_freeze[-1]()
return calendar.timegm(current_time.timetuple()) +
current_time.microsecond / 1000000.0
-class FakeLocalTime(object):
- def __init__(self, time_to_freeze, previous_localtime_function=None):
- self.time_to_freeze = time_to_freeze
+class FakeLocalTime(BaseFakeTime):
+ def __init__(self, previous_localtime_function=None, ignore=None):
self.previous_localtime_function = previous_localtime_function
+ self.ignore = ignore
def __call__(self, t=None):
if t is not None:
return real_localtime(t)
- shifted_time = self.time_to_freeze() -
datetime.timedelta(seconds=time.timezone)
+ if self._should_use_real_time():
+ return real_localtime()
+ shifted_time = times_to_freeze[-1]() -
datetime.timedelta(seconds=time.timezone)
return shifted_time.timetuple()
-class FakeGMTTime(object):
- def __init__(self, time_to_freeze, previous_gmtime_function):
- self.time_to_freeze = time_to_freeze
+class FakeGMTTime(BaseFakeTime):
+ def __init__(self, previous_gmtime_function, ignore=None):
self.previous_gmtime_function = previous_gmtime_function
+ self.ignore = ignore
def __call__(self, t=None):
if t is not None:
return real_gmtime(t)
- return self.time_to_freeze().timetuple()
+ if self._should_use_real_time():
+ return real_gmtime()
+ return times_to_freeze[-1]().timetuple()
-class FakeStrfTime(object):
- def __init__(self, time_to_freeze, previous_strftime_function):
- self.time_to_freeze = time_to_freeze
+class FakeStrfTime(BaseFakeTime):
+ def __init__(self, previous_strftime_function, ignore=None):
self.previous_strftime_function = previous_strftime_function
+ self.ignore = ignore
def __call__(self, format, time_to_format=None):
if time_to_format is None:
- time_to_format = FakeLocalTime(self.time_to_freeze)()
+ if not self._should_use_real_time():
+ time_to_format = FakeLocalTime()()
+
return real_strftime(format, time_to_format)
+class FakeClock(BaseFakeTime):
+ def __init__(self, previous_clock_function, tick=False, ignore=None):
+ self.previous_clock_function = previous_clock_function
+ self.tick = tick
+ self.ignore = ignore
+
+ def __call__(self, *args, **kwargs):
+ if self._should_use_real_time():
+ return real_clock()
+
+ if len(times_to_freeze) == 1:
+ return 0.0 if not self.tick else self.previous_clock_function()
+
+ first_frozen_time = times_to_freeze[0]()
+ last_frozen_time = times_to_freeze[-1]()
+
+ timedelta = (last_frozen_time - first_frozen_time)
+ total_seconds = timedelta.total_seconds()
+
+ if self.tick:
+ total_seconds += self.previous_clock_function()
+
+ return total_seconds
+
+
class FakeDateMeta(type):
@classmethod
def __instancecheck__(self, obj):
@@ -194,9 +252,6 @@
class FakeDate(with_metaclass(FakeDateMeta, real_date)):
- dates_to_freeze = []
- tz_offsets = []
-
def __new__(cls, *args, **kwargs):
return real_date.__new__(cls, *args, **kwargs)
@@ -220,13 +275,13 @@
result = cls._date_to_freeze() + cls._tz_offset()
return date_to_fakedate(result)
- @classmethod
- def _date_to_freeze(cls):
- return cls.dates_to_freeze[-1]()
+ @staticmethod
+ def _date_to_freeze():
+ return times_to_freeze[-1]()
@classmethod
def _tz_offset(cls):
- return cls.tz_offsets[-1]
+ return tz_offsets[-1]
FakeDate.min = date_to_fakedate(real_date.min)
FakeDate.max = date_to_fakedate(real_date.max)
@@ -239,9 +294,6 @@
class FakeDatetime(with_metaclass(FakeDatetimeMeta, real_datetime, FakeDate)):
- times_to_freeze = []
- tz_offsets = []
-
def __new__(cls, *args, **kwargs):
return real_datetime.__new__(cls, *args, **kwargs)
@@ -276,6 +328,13 @@
def date(self):
return date_to_fakedate(self)
+
+ @property
+ def nanosecond(self):
+ try:
+ return real_datetime.nanosecond
+ except AttributeError:
+ return 0
@classmethod
def today(cls):
@@ -286,14 +345,15 @@
result = cls._time_to_freeze() or real_datetime.utcnow()
return datetime_to_fakedatetime(result)
- @classmethod
- def _time_to_freeze(cls):
- if cls.times_to_freeze:
- return cls.times_to_freeze[-1]()
+ @staticmethod
+ def _time_to_freeze():
+ if times_to_freeze:
+ return times_to_freeze[-1]()
@classmethod
def _tz_offset(cls):
- return cls.tz_offsets[-1]
+ return tz_offsets[-1]
+
FakeDatetime.min = datetime_to_fakedatetime(real_datetime.min)
FakeDatetime.max = datetime_to_fakedatetime(real_datetime.max)
@@ -343,6 +403,8 @@
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
else:
time_to_freeze = parser.parse(time_to_freeze_str)
@@ -466,23 +528,29 @@
time_to_freeze = FrozenDateTimeFactory(self.time_to_freeze)
# Change the modules
- datetime.datetime = FakeDatetime
- datetime.datetime.times_to_freeze.append(time_to_freeze)
- datetime.datetime.tz_offsets.append(self.tz_offset)
+ is_already_started = len(times_to_freeze) > 0
+ times_to_freeze.append(time_to_freeze)
+ tz_offsets.append(self.tz_offset)
+
+ if is_already_started:
+ return time_to_freeze
+ datetime.datetime = FakeDatetime
datetime.date = FakeDate
- datetime.date.dates_to_freeze.append(time_to_freeze)
- datetime.date.tz_offsets.append(self.tz_offset)
- fake_time = FakeTime(time_to_freeze, time.time)
- fake_localtime = FakeLocalTime(time_to_freeze, time.localtime)
- fake_gmtime = FakeGMTTime(time_to_freeze, time.gmtime)
- fake_strftime = FakeStrfTime(time_to_freeze, time.strftime)
+ fake_time = FakeTime(time.time, ignore=self.ignore)
+ fake_localtime = FakeLocalTime(time.localtime, ignore=self.ignore)
+ fake_gmtime = FakeGMTTime(time.gmtime, ignore=self.ignore)
+ fake_strftime = FakeStrfTime(time.strftime, ignore=self.ignore)
+ fake_clock = FakeClock(time.clock, tick=self.tick, ignore=self.ignore)
+
time.time = fake_time
time.localtime = fake_localtime
time.gmtime = fake_gmtime
time.strftime = fake_strftime
- uuid._uuid_generate_time = None
+ time.clock = fake_clock
+ if uuid_generate_time_attr:
+ setattr(uuid, uuid_generate_time_attr, None)
uuid._UuidCreate = None
uuid._last_timestamp = None
@@ -497,6 +565,7 @@
('real_localtime', real_localtime, 'FakeLocalTime',
fake_localtime),
('real_strftime', real_strftime, 'FakeStrfTime', fake_strftime),
('real_time', real_time, 'FakeTime', fake_time),
+ ('real_clock', real_clock, 'FakeClock', fake_clock),
]
self.fake_names = tuple(fake_name for real_name, real, fake_name, fake
in to_patch)
self.reals = dict((id(fake), real) for real_name, real, fake_name,
fake in to_patch)
@@ -517,7 +586,7 @@
elif (not hasattr(module, "__name__") or module.__name__ in
('datetime', 'time')):
continue
- module_attrs = _get_cached_module_attributes(mod_name, module)
+ module_attrs = _get_cached_module_attributes(module)
for attribute_name, attribute_value in module_attrs:
fake = fakes.get(id(attribute_value))
if fake:
@@ -527,12 +596,10 @@
return time_to_freeze
def stop(self):
- datetime.datetime.times_to_freeze.pop()
- datetime.datetime.tz_offsets.pop()
- datetime.date.dates_to_freeze.pop()
- datetime.date.tz_offsets.pop()
+ times_to_freeze.pop()
+ tz_offsets.pop()
- if not datetime.datetime.times_to_freeze:
+ if not times_to_freeze:
datetime.datetime = real_datetime
datetime.date = real_date
copyreg.dispatch_table.pop(real_datetime)
@@ -568,14 +635,16 @@
if real:
setattr(module, module_attribute, real)
- time.time = time.time.previous_time_function
- time.gmtime = time.gmtime.previous_gmtime_function
- time.localtime = time.localtime.previous_localtime_function
- time.strftime = time.strftime.previous_strftime_function
-
- uuid._uuid_generate_time = real_uuid_generate_time
- uuid._UuidCreate = real_uuid_create
- uuid._last_timestamp = None
+ time.time = time.time.previous_time_function
+ time.gmtime = time.gmtime.previous_gmtime_function
+ time.localtime = time.localtime.previous_localtime_function
+ time.strftime = time.strftime.previous_strftime_function
+ time.clock = time.clock.previous_clock_function
+
+ if uuid_generate_time_attr:
+ setattr(uuid, uuid_generate_time_attr, real_uuid_generate_time)
+ uuid._UuidCreate = real_uuid_create
+ uuid._last_timestamp = None
def decorate_coroutine(self, coroutine):
return wrap_coroutine(self, coroutine)
@@ -604,10 +673,16 @@
except NameError:
string_type = str
- if not isinstance(time_to_freeze, (type(None), string_type, datetime.date,
- types.FunctionType, types.GeneratorType)):
+ acceptable_times = (type(None), string_type, datetime.date,
datetime.timedelta,
+ types.FunctionType, types.GeneratorType)
+
+ if MayaDT is not None:
+ acceptable_times += MayaDT,
+
+ if not isinstance(time_to_freeze, acceptable_times):
raise TypeError(('freeze_time() expected None, a string, date
instance, datetime '
- 'instance, function or a generator, but got type
{0}.').format(type(time_to_freeze)))
+ 'instance, MayaDT, timedelta instance, function or a
generator, but got '
+ 'type {0}.').format(type(time_to_freeze)))
if tick and not _is_cpython:
raise SystemError('Calling freeze_time with tick=True is only
compatible with CPython')
@@ -617,8 +692,14 @@
if isinstance(time_to_freeze, types.GeneratorType):
return freeze_time(next(time_to_freeze), tz_offset, ignore, tick)
+ if MayaDT is not None and isinstance(time_to_freeze, MayaDT):
+ return freeze_time(time_to_freeze.datetime(), tz_offset, ignore,
+ tick, as_arg)
+
if ignore is None:
ignore = []
+ ignore = ignore[:]
+ ignore.append('nose.plugins')
ignore.append('six.moves')
ignore.append('django.utils.six.moves')
ignore.append('google.gax')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/freezegun.egg-info/PKG-INFO
new/freezegun-0.3.11/freezegun.egg-info/PKG-INFO
--- old/freezegun-0.3.10/freezegun.egg-info/PKG-INFO 2018-03-06
03:54:52.000000000 +0100
+++ new/freezegun-0.3.11/freezegun.egg-info/PKG-INFO 2018-10-15
05:09:26.000000000 +0200
@@ -1,19 +1,241 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
Name: freezegun
-Version: 0.3.10
+Version: 0.3.11
Summary: Let your Python tests travel through time
Home-page: https://github.com/spulec/freezegun
Author: Steve Pulec
Author-email: [email protected]
License: Apache 2.0
Description-Content-Type: UNKNOWN
-Description: UNKNOWN
+Description: FreezeGun: Let your Python tests travel through time
+ ====================================================
+
+
+ .. image::
https://secure.travis-ci.org/spulec/freezegun.svg?branch=master
+ :target: https://travis-ci.org/spulec/freezegun
+ .. image::
https://coveralls.io/repos/spulec/freezegun/badge.svg?branch=master
+ :target: https://coveralls.io/r/spulec/freezegun
+
+ FreezeGun is a library that allows your Python tests to travel through
time by mocking the datetime module.
+
+ 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.
+
+ Decorator
+ ~~~~~~~~~
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+ import datetime
+ import unittest
+
+
+ @freeze_time("2012-01-14")
+ def test():
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
14)
+
+ # Or a unittest TestCase - freezes for every test, from the start
of setUpClass to the end of tearDownClass
+
+ @freeze_time("1955-11-12")
+ class MyTests(unittest.TestCase):
+ def test_the_class(self):
+ assert datetime.datetime.now() == datetime.datetime(1955,
11, 12)
+
+ # Or any other class - freezes around each callable (may not work
in every case)
+
+ @freeze_time("2012-01-14")
+ class Tester(object):
+ def test_the_class(self):
+ assert datetime.datetime.now() == datetime.datetime(2012,
1, 14)
+
+ Context manager
+ ~~~~~~~~~~~~~~~
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+
+ def test():
+ assert datetime.datetime.now() != datetime.datetime(2012, 1,
14)
+ with freeze_time("2012-01-14"):
+ assert datetime.datetime.now() == datetime.datetime(2012,
1, 14)
+ assert datetime.datetime.now() != datetime.datetime(2012, 1,
14)
+
+ Raw use
+ ~~~~~~~
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+
+ freezer = freeze_time("2012-01-14 12:00:01")
+ freezer.start()
+ assert datetime.datetime.now() == datetime.datetime(2012, 1, 14,
12, 0, 1)
+ freezer.stop()
+
+ Timezones
+ ~~~~~~~~~
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+
+ @freeze_time("2012-01-14 03:21:34", tz_offset=-4)
+ def test():
+ assert datetime.datetime.utcnow() == datetime.datetime(2012,
1, 14, 3, 21, 34)
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
13, 23, 21, 34)
+
+ # datetime.date.today() uses local time
+ assert datetime.date.today() == datetime.date(2012, 1, 13)
+
+ @freeze_time("2012-01-14 03:21:34",
tz_offset=-datetime.timedelta(hours=3, minutes=30))
+ def test_timedelta_offset():
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
13, 23, 51, 34)
+
+ Nice inputs
+ ~~~~~~~~~~~
+
+ FreezeGun uses dateutil behind the scenes so you can have nice-looking
datetimes.
+
+ .. code-block:: python
+
+ @freeze_time("Jan 14th, 2012")
+ def test_nice_datetime():
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
14)
+
+ Function and generator objects
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ FreezeGun is able to handle function and generator objects.
+
+ .. code-block:: python
+
+ def test_lambda():
+ with freeze_time(lambda: datetime.datetime(2012, 1, 14)):
+ assert datetime.datetime.now() == datetime.datetime(2012,
1, 14)
+
+ def test_generator():
+ datetimes = (datetime.datetime(year, 1, 1) for year in
range(2010, 2012))
+
+ with freeze_time(datetimes):
+ assert datetime.datetime.now() == datetime.datetime(2010,
1, 1)
+
+ with freeze_time(datetimes):
+ assert datetime.datetime.now() == datetime.datetime(2011,
1, 1)
+
+ # The next call to freeze_time(datetimes) would raise a
StopIteration exception.
+
+ ``tick`` argument
+ ~~~~~~~~~~~~~~~~~
+
+ FreezeGun has an additional ``tick`` argument which will restart time
at the given
+ value, but then time will keep ticking. This is alternative to the
default
+ parameters which will keep time stopped.
+
+ .. code-block:: python
+
+ @freeze_time("Jan 14th, 2020", tick=True)
+ def test_nice_datetime():
+ assert datetime.datetime.now() > datetime.datetime(2020, 1, 14)
+
+ Manual ticks
+ ~~~~~~~~~~~~
+
+ FreezeGun allows for the time to be manually forwarded as well.
+
+ .. code-block:: python
+
+ def test_manual_increment():
+ initial_datetime = datetime.datetime(year=1, month=7, day=12,
+ hour=15, minute=6,
second=3)
+ with freeze_time(initial_datetime) as frozen_datetime:
+ assert frozen_datetime() == initial_datetime
+
+ frozen_datetime.tick()
+ initial_datetime += datetime.timedelta(seconds=1)
+ assert frozen_datetime() == initial_datetime
+
+ frozen_datetime.tick(delta=datetime.timedelta(seconds=10))
+ initial_datetime += datetime.timedelta(seconds=10)
+ assert frozen_datetime() == initial_datetime
+
+ Moving time to specify datetime
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ FreezeGun allows moving time to specific dates.
+
+ .. code-block:: python
+
+ def test_move_to():
+ initial_datetime = datetime.datetime(year=1, month=7, day=12,
+ hour=15, minute=6,
second=3)
+
+ other_datetime = datetime.datetime(year=2, month=8, day=13,
+ hour=14, minute=5,
second=0)
+ with freeze_time(initial_datetime) as frozen_datetime:
+ assert frozen_datetime() == initial_datetime
+
+ frozen_datetime.move_to(other_datetime)
+ assert frozen_datetime() == other_datetime
+
+ frozen_datetime.move_to(initial_datetime)
+ assert frozen_datetime() == initial_datetime
+
+
+ @freeze_time("2012-01-14", as_arg=True)
+ def test(frozen_time):
+ assert datetime.datetime.now() == datetime.datetime(2012, 1,
14)
+ frozen_time.move_to("2014-02-12")
+ assert datetime.datetime.now() == datetime.datetime(2014, 2,
12)
+
+ Parameter for ``move_to`` can be any valid ``freeze_time`` date
(string, date, datetime).
+
+
+ Default arguments
+ ~~~~~~~~~~~~~~~~~
+
+ Note that FreezeGun will not modify default arguments. The following
code will
+ print the current date. See `here
<http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments>`_
for why.
+
+ .. code-block:: python
+
+ from freezegun import freeze_time
+ import datetime as dt
+
+ def test(default=dt.date.today()):
+ print(default)
+
+ with freeze_time('2000-1-1'):
+ test()
+
+
+ Installation
+ ------------
+
+ To install FreezeGun, simply:
+
+ .. code-block:: bash
+
+ $ pip install freezegun
+
+ On Debian (Testing and Unstable) systems:
+
+ .. code-block:: bash
+
+ $ sudo apt-get install python-freezegun
+
Platform: UNKNOWN
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/setup.py
new/freezegun-0.3.11/setup.py
--- old/freezegun-0.3.10/setup.py 2018-03-06 03:54:04.000000000 +0100
+++ new/freezegun-0.3.11/setup.py 2018-10-15 05:05:29.000000000 +0200
@@ -4,36 +4,42 @@
from setuptools import setup
requires = ['six']
+tests_require = ['mock', 'nose']
-if sys.version_info[0] == 2:
+if sys.version_info.major == 2:
requires += ['python-dateutil>=1.0, != 2.0']
else:
# Py3k
requires += ['python-dateutil>=2.0']
+
with open('README.rst') as f:
readme = f.read()
setup(
name='freezegun',
- version='0.3.10',
+ version='0.3.11',
description='Let your Python tests travel through time',
- long_desciption=readme,
+ long_description=readme,
author='Steve Pulec',
author_email='[email protected]',
url='https://github.com/spulec/freezegun',
packages=['freezegun'],
install_requires=requires,
+ tests_require=tests_require,
include_package_data=True,
license='Apache 2.0',
+ python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
classifiers=[
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
+ 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: Implementation :: CPython',
+ 'Programming Language :: Python :: Implementation :: PyPy',
],
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/tests/test_class_import.py
new/freezegun-0.3.11/tests/test_class_import.py
--- old/freezegun-0.3.10/tests/test_class_import.py 2018-03-06
01:33:10.000000000 +0100
+++ new/freezegun-0.3.11/tests/test_class_import.py 2018-10-15
04:31:36.000000000 +0200
@@ -70,6 +70,28 @@
freezer.stop()
+def test_fake_uses_real_when_ignored():
+ real_time_before = time.time()
+ with freeze_time('2012-01-14', ignore=['tests.fake_module']):
+ real_time = fake_time_function()
+ real_time_after = time.time()
+ assert real_time_before <= real_time <= real_time_after
+
+
+def test_can_ignore_email_module():
+ from email.utils import formatdate
+ with freeze_time('2012-01-14'):
+ faked_date_str = formatdate()
+
+ before_date_str = formatdate()
+ with freeze_time('2012-01-14', ignore=['email']):
+ date_str = formatdate()
+
+ after_date_str = formatdate()
+ assert date_str != faked_date_str
+ assert before_date_str <= date_str <= after_date_str
+
+
@freeze_time('2011-01-01')
def test_avoid_replacing_equal_to_anything():
assert fake_module.equal_to_anything.description == 'This is the
equal_to_anything object'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/tests/test_datetimes.py
new/freezegun-0.3.11/tests/test_datetimes.py
--- old/freezegun-0.3.10/tests/test_datetimes.py 2018-03-06
03:30:32.000000000 +0100
+++ new/freezegun-0.3.11/tests/test_datetimes.py 2018-10-15
04:58:23.000000000 +0200
@@ -9,7 +9,13 @@
from tests import utils
from freezegun import freeze_time
-from freezegun.api import FakeDatetime, FakeDate
+from freezegun.api import FakeDatetime, FakeDate, BaseFakeTime
+
+try:
+ import maya
+
+except ImportError:
+ maya = None
class temp_locale(object):
@@ -201,6 +207,17 @@
assert time_struct.tm_isdst == -1
+def test_time_clock():
+ with freeze_time('2012-01-14 03:21:34'):
+ assert time.clock() == 0
+
+ with freeze_time('2012-01-14 03:21:35'):
+ assert time.clock() == 1
+
+ with freeze_time('2012-01-14 03:21:36'):
+ assert time.clock() == 2
+
+
class modify_timezone(object):
def __init__(self, new_timezone):
@@ -302,6 +319,19 @@
assert_raises(StopIteration, freeze_time, frozen_datetimes)
+def test_maya_datetimes():
+ if not maya:
+ raise skip.SkipTest("maya is optional since it's not supported for "
+ "enough python versions")
+
+ with freeze_time(maya.when("October 2nd, 1997")):
+ assert datetime.datetime.now() == datetime.datetime(
+ year=1997,
+ month=10,
+ day=2
+ )
+
+
def test_old_datetime_object():
frozen_datetime = datetime.datetime(year=1, month=7, day=12,
hour=15, minute=6, second=3)
@@ -578,3 +608,37 @@
utc_now = datetime.datetime.utcnow()
assert utc_now.tzinfo is None
assert utc_now == datetime.datetime(1970, 1, 1, 4)
+
+
+@freeze_time('2015-01-01')
+def test_time_with_nested():
+ from time import time
+ first = 1420070400.0
+ second = 1420070760.0
+
+ assert time() == first
+ with freeze_time('2015-01-01T00:06:00'):
+ assert time() == second
+
+
+def test_should_use_real_time():
+ frozen = datetime.datetime(2015, 3, 5)
+ expected_frozen = 1425513600.0
+ # TODO: local time seems to leak the local timezone, so this test fails in
CI
+ # expected_frozen_local = (2015, 3, 5, 1, 0, 0, 3, 64, -1)
+ expected_frozen_gmt = (2015, 3, 5, 0, 0, 0, 3, 64, -1)
+ expected_clock = 0
+
+ BaseFakeTime.call_stack_inspection_limit = 100 # just to increase coverage
+
+ with freeze_time(frozen):
+ assert time.time() == expected_frozen
+ # assert time.localtime() == expected_frozen_local
+ assert time.gmtime() == expected_frozen_gmt
+ assert time.clock() == expected_clock
+
+ with freeze_time(frozen, ignore=['_pytest', 'nose']):
+ assert time.time() != expected_frozen
+ # assert time.localtime() != expected_frozen_local
+ assert time.gmtime() != expected_frozen_gmt
+ assert time.clock() != expected_clock
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/freezegun-0.3.10/tests/test_ticking.py
new/freezegun-0.3.11/tests/test_ticking.py
--- old/freezegun-0.3.10/tests/test_ticking.py 2018-03-06 01:33:10.000000000
+0100
+++ new/freezegun-0.3.11/tests/test_ticking.py 2018-10-15 04:58:23.000000000
+0200
@@ -14,6 +14,38 @@
@utils.cpython_only
+def test_ticking_time_clock():
+ with freeze_time('2012-01-14 03:21:34', tick=True):
+ first = time.clock()
+ time.sleep(0.001) # Deal with potential clock resolution problems
+ with freeze_time('2012-01-14 03:21:35', tick=True):
+ second = time.clock()
+ time.sleep(0.001) # Deal with potential clock resolution problems
+
+ with freeze_time('2012-01-14 03:21:36', tick=True):
+ third = time.clock()
+ time.sleep(0.001)
+
+ # Rewind time backwards
+ with freeze_time('2012-01-14 03:20:00', tick=True):
+ fourth = time.clock()
+ time.sleep(0.001)
+ fifth = time.clock()
+
+ assert first > 0
+ assert second > first
+ assert second > 1
+ assert third > second
+ assert third > 2
+
+ assert third > fourth
+ assert second > fourth
+ assert first > fourth
+
+ assert fifth > fourth
+
+
[email protected]_only
def test_ticking_date():
with freeze_time("Jan 14th, 2012, 23:59:59.9999999", tick=True):
time.sleep(0.001) # Deal with potential clock resolution problems