freezegun-0.3.5/0000755000076500000240000000000012560662237014140 5ustar spulecstaff00000000000000freezegun-0.3.5/AUTHORS.rst0000644000076500000240000000074112557140450016013 0ustar spulecstaff00000000000000Patches and Suggestions ``````````````````````` - `Dan Miller `_ - `Matthew Schinckel `_ - `JJ Geewax `_ - `Roman Imankulov `_ - `Martin Geisler `_ - `Richard Eames `_ - `Tye Wang `_ - `Andreas Pelme `_ - `Jesse London `_ freezegun-0.3.5/freezegun/0000755000076500000240000000000012560662237016132 5ustar spulecstaff00000000000000freezegun-0.3.5/freezegun/__init__.py0000644000076500000240000000045712560662161020245 0ustar spulecstaff00000000000000# -*- coding: utf-8 -*- """ freezegun ~~~~~~~~ :copyright: (c) 2012 by Steve Pulec. """ __title__ = 'freezegun' __version__ = '0.3.5' __author__ = 'Steve Pulec' __license__ = 'Apache License 2.0' __copyright__ = 'Copyright 2012 Steve Pulec' from .api import freeze_time __all__ = ["freeze_time"] freezegun-0.3.5/freezegun/api.py0000644000076500000240000003571212560662146017264 0ustar spulecstaff00000000000000import datetime import functools import inspect import sys import time import calendar import unittest import platform from dateutil import parser real_time = time.time real_localtime = time.localtime real_gmtime = time.gmtime real_strftime = time.strftime real_date = datetime.date real_datetime = datetime.datetime try: import copy_reg as copyreg except ImportError: import copyreg # Stolen from six def with_metaclass(meta, *bases): """Create a base class with a metaclass.""" return meta("NewBase", bases, {}) def _is_cpython(): return platform.python_implementation() == "CPython" class FakeTime(object): def __init__(self, time_to_freeze, previous_time_function): self.time_to_freeze = time_to_freeze self.previous_time_function = previous_time_function def __call__(self): current_time = self.time_to_freeze() return calendar.timegm(current_time.timetuple()) + current_time.microsecond / 1000000.0 class FakeLocalTime(object): def __init__(self, time_to_freeze): self.time_to_freeze = time_to_freeze 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) return shifted_time.timetuple() class FakeGMTTime(object): def __init__(self, time_to_freeze, previous_gmtime_function): self.time_to_freeze = time_to_freeze self.previous_gmtime_function = previous_gmtime_function def __call__(self, t=None): if t is not None: return real_gmtime(t) return self.time_to_freeze().timetuple() class FakeStrfTime(object): def __init__(self, time_to_freeze): self.time_to_freeze = time_to_freeze def __call__(self, format, time_to_format=None): if time_to_format is None: time_to_format = FakeLocalTime(self.time_to_freeze)() return real_strftime(format, time_to_format) class FakeDateMeta(type): @classmethod def __instancecheck__(self, obj): return isinstance(obj, real_date) def datetime_to_fakedatetime(datetime): return FakeDatetime(datetime.year, datetime.month, datetime.day, datetime.hour, datetime.minute, datetime.second, datetime.microsecond, datetime.tzinfo) def date_to_fakedate(date): return FakeDate(date.year, date.month, date.day) class FakeDate(with_metaclass(FakeDateMeta, real_date)): dates_to_freeze = [] tz_offsets = [] def __new__(cls, *args, **kwargs): return real_date.__new__(cls, *args, **kwargs) def __add__(self, other): result = real_date.__add__(self, other) if result is NotImplemented: return result return date_to_fakedate(result) def __sub__(self, other): result = real_date.__sub__(self, other) if result is NotImplemented: return result if isinstance(result, real_date): return date_to_fakedate(result) else: return result @classmethod def today(cls): result = cls._date_to_freeze() + datetime.timedelta(hours=cls._tz_offset()) return date_to_fakedate(result) @classmethod def _date_to_freeze(cls): return cls.dates_to_freeze[-1]() @classmethod def _tz_offset(cls): return cls.tz_offsets[-1] FakeDate.min = date_to_fakedate(real_date.min) FakeDate.max = date_to_fakedate(real_date.max) class FakeDatetimeMeta(FakeDateMeta): @classmethod def __instancecheck__(self, obj): return isinstance(obj, real_datetime) 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) def __add__(self, other): result = real_datetime.__add__(self, other) if result is NotImplemented: return result return datetime_to_fakedatetime(result) def __sub__(self, other): result = real_datetime.__sub__(self, other) if result is NotImplemented: return result if isinstance(result, real_datetime): return datetime_to_fakedatetime(result) else: return result def astimezone(self, tz): return datetime_to_fakedatetime(real_datetime.astimezone(self, tz)) @classmethod def now(cls, tz=None): if tz: result = tz.fromutc(cls._time_to_freeze().replace(tzinfo=tz)) + datetime.timedelta(hours=cls._tz_offset()) else: result = cls._time_to_freeze() + datetime.timedelta(hours=cls._tz_offset()) return datetime_to_fakedatetime(result) def date(self): return date_to_fakedate(self) @classmethod def today(cls): return cls.now(tz=None) @classmethod def utcnow(cls): result = cls._time_to_freeze() return datetime_to_fakedatetime(result) @classmethod def _time_to_freeze(cls): return cls.times_to_freeze[-1]() @classmethod def _tz_offset(cls): return cls.tz_offsets[-1] FakeDatetime.min = datetime_to_fakedatetime(real_datetime.min) FakeDatetime.max = datetime_to_fakedatetime(real_datetime.max) def convert_to_timezone_naive(time_to_freeze): """ Converts a potentially timezone-aware datetime to be a naive UTC datetime """ if time_to_freeze.tzinfo: time_to_freeze -= time_to_freeze.utcoffset() time_to_freeze = time_to_freeze.replace(tzinfo=None) return time_to_freeze def pickle_fake_date(datetime_): # A pickle function for FakeDate return FakeDate, (datetime_.year, datetime_.month, datetime_.day, ) def pickle_fake_datetime(datetime_): # A pickle function for FakeDatetime return FakeDatetime, (datetime_.year, datetime_.month, datetime_.day, datetime_.hour, datetime_.minute, datetime_.second, datetime_.microsecond, datetime_.tzinfo, ) class TickingDateTimeFactory(object): def __init__(self, time_to_freeze, start): self.time_to_freeze = time_to_freeze self.start = start def __call__(self): return self.time_to_freeze + (real_datetime.now() - self.start) class FrozenDateTimeFactory(object): def __init__(self, time_to_freeze): self.time_to_freeze = time_to_freeze def __call__(self): return self.time_to_freeze class _freeze_time(object): def __init__(self, time_to_freeze_str, tz_offset, ignore, tick): 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()) else: time_to_freeze = parser.parse(time_to_freeze_str) time_to_freeze = convert_to_timezone_naive(time_to_freeze) self.time_to_freeze = time_to_freeze self.tz_offset = tz_offset self.ignore = tuple(ignore) self.tick = tick self.undo_changes = [] def __call__(self, func): if inspect.isclass(func): return self.decorate_class(func) return self.decorate_callable(func) def decorate_class(self, klass): if issubclass(klass, unittest.TestCase): # If it's a TestCase, we assume you want to freeze the time for the # tests, from setUpClass to tearDownClass # Use getattr as in Python 2.6 they are optional orig_setUpClass = getattr(klass, 'setUpClass', None) orig_tearDownClass = getattr(klass, 'tearDownClass', None) @classmethod def setUpClass(cls): self.start() if orig_setUpClass is not None: orig_setUpClass() @classmethod def tearDownClass(cls): if orig_tearDownClass is not None: orig_tearDownClass() self.stop() klass.setUpClass = setUpClass klass.tearDownClass = tearDownClass return klass else: seen = set() for base_klass in klass.mro(): for (attr, attr_value) in base_klass.__dict__.items(): if attr.startswith('_') or attr in seen: continue seen.add(attr) if not callable(attr_value) or inspect.isclass(attr_value): continue try: setattr(klass, attr, self(attr_value)) except (AttributeError, TypeError): # Sometimes we can't set this for built-in types and custom callables continue return klass def __enter__(self): self.start() def __exit__(self, *args): self.stop() def start(self): if self.tick: time_to_freeze = TickingDateTimeFactory(self.time_to_freeze, real_datetime.now()) else: time_to_freeze = FrozenDateTimeFactory(self.time_to_freeze) # Change the modules datetime.datetime = FakeDatetime datetime.date = FakeDate fake_time = FakeTime(time_to_freeze, time.time) fake_localtime = FakeLocalTime(time_to_freeze) fake_gmtime = FakeGMTTime(time_to_freeze, time.gmtime) fake_strftime = FakeStrfTime(time_to_freeze) time.time = fake_time time.localtime = fake_localtime time.gmtime = fake_gmtime time.strftime = fake_strftime copyreg.dispatch_table[real_datetime] = pickle_fake_datetime copyreg.dispatch_table[real_date] = pickle_fake_date # Change any place where the module had already been imported real_things = ( real_time, real_localtime, real_gmtime, real_strftime, real_date, real_datetime ) add_change = self.undo_changes.append for mod_name, module in list(sys.modules.items()): if mod_name is None or module is None: continue elif mod_name.startswith(self.ignore): continue elif (not hasattr(module, "__name__") or module.__name__ in ('datetime', 'time')): continue for module_attribute in dir(module): if module_attribute in ('real_date', 'real_datetime', 'real_time', 'real_localtime', 'real_gmtime', 'real_strftime'): continue try: attribute_value = getattr(module, module_attribute) except (ImportError, AttributeError): # For certain libraries, this can result in ImportError(_winreg) or AttributeError (celery) continue try: if attribute_value not in real_things: continue if attribute_value is real_datetime: setattr(module, module_attribute, FakeDatetime) add_change((module, module_attribute, real_datetime)) elif attribute_value is real_date: setattr(module, module_attribute, FakeDate) add_change((module, module_attribute, real_date)) elif attribute_value is real_time: setattr(module, module_attribute, fake_time) add_change((module, module_attribute, real_time)) elif attribute_value is real_localtime: setattr(module, module_attribute, fake_localtime) add_change((module, module_attribute, real_localtime)) elif attribute_value is real_gmtime: setattr(module, module_attribute, fake_gmtime) add_change((module, module_attribute, real_gmtime)) elif attribute_value is real_strftime: setattr(module, module_attribute, fake_strftime) add_change((module, module_attribute, real_strftime)) except: # If it's not possible to compare the value to real_XXX (e.g. hiredis.version) pass datetime.datetime.times_to_freeze.append(time_to_freeze) datetime.datetime.tz_offsets.append(self.tz_offset) datetime.date.dates_to_freeze.append(time_to_freeze) datetime.date.tz_offsets.append(self.tz_offset) 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() if not datetime.datetime.times_to_freeze: datetime.datetime = real_datetime 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) self.undo_changes = [] time.time = time.time.previous_time_function time.gmtime = time.gmtime.previous_gmtime_function def decorate_callable(self, func): def wrapper(*args, **kwargs): with self: result = func(*args, **kwargs) return result functools.update_wrapper(wrapper, func) # update_wrapper already sets __wrapped__ in Python 3.2+, this is only # needed for Python 2.x support wrapper.__wrapped__ = func return wrapper def freeze_time(time_to_freeze, tz_offset=0, ignore=None, tick=False): # Python3 doesn't have basestring, but it does have str. try: string_type = basestring except NameError: string_type = str if not isinstance(time_to_freeze, (string_type, datetime.date)): raise TypeError(('freeze_time() expected a string, date instance, or ' 'datetime instance, 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') if ignore is None: ignore = [] ignore.append('six.moves') ignore.append('django.utils.six.moves') return _freeze_time(time_to_freeze, tz_offset, ignore, tick) # Setup adapters for sqlite try: import sqlite3 except ImportError: # Some systems have trouble with this pass else: # These are copied from Python sqlite3.dbapi2 def adapt_date(val): return val.isoformat() def adapt_datetime(val): return val.isoformat(" ") sqlite3.register_adapter(FakeDate, adapt_date) sqlite3.register_adapter(FakeDatetime, adapt_datetime) freezegun-0.3.5/freezegun.egg-info/0000755000076500000240000000000012560662237017624 5ustar spulecstaff00000000000000freezegun-0.3.5/freezegun.egg-info/dependency_links.txt0000644000076500000240000000000112560662237023672 0ustar spulecstaff00000000000000 freezegun-0.3.5/freezegun.egg-info/PKG-INFO0000644000076500000240000000076412560662237020730 0ustar spulecstaff00000000000000Metadata-Version: 1.1 Name: freezegun Version: 0.3.5 Summary: Let your Python tests travel through time Home-page: https://github.com/spulec/freezegun Author: Steve Pulec Author-email: spulec@gmail License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN 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 freezegun-0.3.5/freezegun.egg-info/requires.txt0000644000076500000240000000004112560662237022217 0ustar spulecstaff00000000000000six python-dateutil>=1.0, != 2.0 freezegun-0.3.5/freezegun.egg-info/SOURCES.txt0000644000076500000240000000247012560662237021513 0ustar spulecstaff00000000000000AUTHORS.rst LICENSE MANIFEST.in README.rst setup.cfg setup.py freezegun/__init__.py freezegun/api.py freezegun.egg-info/PKG-INFO freezegun.egg-info/SOURCES.txt freezegun.egg-info/dependency_links.txt freezegun.egg-info/requires.txt freezegun.egg-info/top_level.txt tests/__init__.py tests/__init__.pyc tests/fake_module.py tests/fake_module.pyc tests/single_import_module.pyc tests/test_class_import.py tests/test_class_import.pyc tests/test_datetimes.py tests/test_datetimes.pyc tests/test_import_alias.py tests/test_import_alias.pyc tests/test_operations.py tests/test_operations.pyc tests/test_pickle.py tests/test_pickle.pyc tests/test_sqlite2.pyc tests/test_sqlite3.py tests/test_sqlite3.pyc tests/test_test.pyc tests/test_ticking.py tests/utils.py tests/utils.pyc tests/__pycache__/__init__.cpython-33.pyc tests/__pycache__/fake_module.cpython-33.pyc tests/__pycache__/test_class_import.cpython-27-PYTEST.pyc tests/__pycache__/test_class_import.cpython-33.pyc tests/__pycache__/test_datetimes.cpython-27-PYTEST.pyc tests/__pycache__/test_datetimes.cpython-33.pyc tests/__pycache__/test_import_alias.cpython-27-PYTEST.pyc tests/__pycache__/test_operations.cpython-27-PYTEST.pyc tests/__pycache__/test_operations.cpython-33.pyc tests/__pycache__/test_pickle.cpython-27-PYTEST.pyc tests/__pycache__/test_sqlite3.cpython-27-PYTEST.pycfreezegun-0.3.5/freezegun.egg-info/top_level.txt0000644000076500000240000000001212560662237022347 0ustar spulecstaff00000000000000freezegun freezegun-0.3.5/LICENSE0000644000076500000240000002512212061520467015141 0ustar spulecstaff00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2012 Steve Pulec Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.freezegun-0.3.5/MANIFEST.in0000644000076500000240000000010112557140450015660 0ustar spulecstaff00000000000000include README.rst LICENSE AUTHORS.rst recursive-include tests * freezegun-0.3.5/PKG-INFO0000644000076500000240000000076412560662237015244 0ustar spulecstaff00000000000000Metadata-Version: 1.1 Name: freezegun Version: 0.3.5 Summary: Let your Python tests travel through time Home-page: https://github.com/spulec/freezegun Author: Steve Pulec Author-email: spulec@gmail License: UNKNOWN Description: UNKNOWN Platform: UNKNOWN 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 freezegun-0.3.5/README.rst0000644000076500000240000000577312557140450015635 0ustar spulecstaff00000000000000FreezeGun: Let your Python tests travel through time ==================================================== .. image:: https://secure.travis-ci.org/spulec/freezegun.png?branch=master :target: https://travis-ci.org/spulec/freezegun .. image:: https://coveralls.io/repos/spulec/freezegun/badge.png?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 @freeze_time("2012-01-14") def test(): assert datetime.datetime.now() == datetime.datetime(2012, 01, 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(2012, 01, 14) # 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, 01, 14) Context Manager ~~~~~~~~~~~~~~~ .. code-block:: python from freezegun import freeze_time def test(): assert datetime.datetime.now() != datetime.datetime(2012, 01, 14) with freeze_time("2012-01-14"): assert datetime.datetime.now() == datetime.datetime(2012, 01, 14) assert datetime.datetime.now() != datetime.datetime(2012, 01, 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, 01, 14, 12, 00, 01) 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, 01, 14, 03, 21, 34) assert datetime.datetime.now() == datetime.datetime(2012, 01, 13, 23, 21, 34) # datetime.date.today() uses local time assert datetime.date.today() == datetime.date(2012, 01, 13) 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, 01, 14) 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 freezegun-0.3.5/setup.cfg0000644000076500000240000000026312560662237015762 0ustar spulecstaff00000000000000[nosetests] verbosity = 1 detailed-errors = 1 with-coverage = 1 cover-package = freezegun [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 freezegun-0.3.5/setup.py0000644000076500000240000000145312560662165015655 0ustar spulecstaff00000000000000#!/usr/bin/env python import sys from setuptools import setup, find_packages requires = ['six'] if sys.version_info[0] == 2: requires += ['python-dateutil>=1.0, != 2.0'] else: # Py3k requires += ['python-dateutil>=2.0'] setup( name='freezegun', version='0.3.5', description='Let your Python tests travel through time', author='Steve Pulec', author_email='spulec@gmail', url='https://github.com/spulec/freezegun', packages=['freezegun'], install_requires=requires, include_package_data=True, classifiers=[ 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', ], ) freezegun-0.3.5/tests/0000755000076500000240000000000012560662237015302 5ustar spulecstaff00000000000000freezegun-0.3.5/tests/__init__.py0000644000076500000240000000000012161103062017360 0ustar spulecstaff00000000000000freezegun-0.3.5/tests/__init__.pyc0000644000076500000240000000021412416600237017543 0ustar spulecstaff00000000000000ó 2†ÄQc@sdS(N((((s5/Users/spulec/Development/freezegun/tests/__init__.pytsfreezegun-0.3.5/tests/__pycache__/0000755000076500000240000000000012560662237017512 5ustar spulecstaff00000000000000freezegun-0.3.5/tests/__pycache__/__init__.cpython-33.pyc0000644000076500000240000000022412161103373023656 0ustar spulecstaff00000000000000ž 2†ÄQc@sdS(N((((u5/Users/spulec/Development/freezegun/tests/__init__.pyusfreezegun-0.3.5/tests/__pycache__/fake_module.cpython-33.pyc0000644000076500000240000000133212161103373024373 0ustar spulecstaff00000000000000ž ±™NQ¦c@s<ddlmZddlmZdd„Zdd„ZdS(i(udatetime(udatecCs tjƒS(N(udatetimeunow(((u8/Users/spulec/Development/freezegun/tests/fake_module.pyufake_datetime_functionsufake_datetime_functioncCs tjƒS(N(udateutoday(((u8/Users/spulec/Development/freezegun/tests/fake_module.pyufake_date_function sufake_date_functionN(udatetimeudateufake_datetime_functionufake_date_function(((u8/Users/spulec/Development/freezegun/tests/fake_module.pyus freezegun-0.3.5/tests/__pycache__/test_class_import.cpython-27-PYTEST.pyc0000644000076500000240000001063512464570514026730 0ustar spulecstaff00000000000000ó HñÒT c@sOddlZddljjZddlZddlZddlm Z m Z m Z m Z m Z mZmZddlmZddlmZddlmZddlZedƒd„ƒZedƒd „ƒZedƒd „ƒZd „Zd „Zed ƒd„ƒZedƒd„ƒZedƒd„ƒZedƒd„ƒZdS(iÿÿÿÿNi(tequal_to_anythingtfake_date_functiontfake_datetime_functiontfake_gmtime_functiontfake_localtime_functiontfake_strftime_functiontfake_time_function(t fake_module(t freeze_time(t FakeDatetimes 2012-01-14cCstƒjjjdƒdS(Ni(Rtdaytshouldtequal(((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_import_datetime_worksscCstƒjjjdƒdS(Ni(RR R R (((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_import_date_worksscCsZtjdddƒ}|tjdtjƒ}tj|jƒƒ}tƒjj|ƒdS(NiÜiitseconds( tdatetimet timedeltattimettimezonetmktimet timetupleRR R (t local_timetutc_timetexpected_timestamp((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_import_timescCsÍtdƒ}tƒ}|jjjtjƒ|jjjtƒ|jƒtƒj jjdƒtƒjj j tjƒtƒjj j tƒ|j ƒtƒ}|jjjtjƒ|jjjtƒdS(Ns 2012-01-14i( RRt __class__R R RtshouldntR tstartR tbetatstop(tfreezertresult((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_start_and_stop_works$s     cCs²tjjƒ}tjjƒ}tdƒ}|jƒt|tjƒjjt ƒt|tjƒjjt ƒt|tjƒjjt ƒt|tjƒjjt ƒ|j ƒdS(Ns 2011-01-01( RtdatettodaytnowRRt isinstanceR R tTruetFalseR(R#R%R ((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_isinstance_works6s  s 2011-01-01cCsõtj}|j}d}||k}|sßtjd |fd ||fƒidtjƒksltjtƒr{tjtƒndd6tj|ƒd6tj|ƒd6tj|ƒd6}di|d 6}t tj |ƒƒ‚nd}}}}dS(Ns$This is the equal_to_anything objects==sZ%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.equal_to_anything }.description } == %(py7)sRtpy0tpy2tpy4tpy7tsassert %(py9)stpy9(s==(sZ%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.equal_to_anything }.description } == %(py7)ssassert %(py9)s( RRt descriptiont @pytest_art_call_reprcomparet @py_builtinstlocalst_should_repr_global_namet _safereprtAssertionErrort_format_explanationtNone(t @py_assert1t @py_assert3t @py_assert6t @py_assert5t @py_format8t @py_format10((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyt&test_avoid_replacing_equal_to_anythingCs  ŒcCstƒjjdƒdS(Niê(RR R (((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_import_localtimeHscCstƒjjdƒdS(Niê(RR R (((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_fake_gmtime_functionMscCstƒjjdƒdS(NiÒ(RR R (((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_fake_strftime_functionRs(t __builtin__R3t_pytest.assertion.rewritet assertiontrewriteR1tsureRRRRRRRRRR.t freezegunRt freezegun.apiR RR RRR"R)R@RARBRC(((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyts"   4    freezegun-0.3.5/tests/__pycache__/test_class_import.cpython-33.pyc0000644000076500000240000000460012161103373025657 0ustar spulecstaff00000000000000ž ½„ÄQMc@sšddlZddlmZmZddlmZddlmZddlZedƒdd„ƒZ edƒd d „ƒZ d d „Z d d„Z dS(iNi(ufake_datetime_functionufake_date_function(u freeze_time(u FakeDatetimeu 2012-01-14cCstƒjjjdƒdS(Ni(ufake_datetime_functionudayushoulduequal(((u>/Users/spulec/Development/freezegun/tests/test_class_import.pyutest_import_datetime_works sutest_import_datetime_workscCstƒjjjdƒdS(Ni(ufake_date_functionudayushoulduequal(((u>/Users/spulec/Development/freezegun/tests/test_class_import.pyutest_import_date_workssutest_import_date_workscCsÍtdƒ}tƒ}|jjjtjƒ|jjjtƒ|jƒtƒj jjdƒtƒjj j tjƒtƒjj j tƒ|j ƒtƒ}|jjjtjƒ|jjjtƒdS(Nu 2012-01-14i( u freeze_timeufake_datetime_functionu __class__ushoulduequaludatetimeushouldntu FakeDatetimeustartudayubeuaustop(ufreezeruresult((u>/Users/spulec/Development/freezegun/tests/test_class_import.pyutest_start_and_stop_workss     utest_start_and_stop_workscCs²tjjƒ}tjjƒ}tdƒ}|jƒt|tjƒjjdƒt|tjƒjjdƒt|tjƒjjdƒt|tjƒjjdƒ|j ƒdS(Nu 2011-01-01TF( udatetimeudateutodayunowu freeze_timeustartu isinstanceushoulduequaluTrueuFalseustop(udateunowufreezer((u>/Users/spulec/Development/freezegun/tests/test_class_import.pyutest_isinstance_works%s  utest_isinstance_works( usureu fake_moduleufake_datetime_functionufake_date_functionu freezegunu freeze_timeu freezegun.apiu FakeDatetimeudatetimeutest_import_datetime_worksutest_import_date_worksutest_start_and_stop_worksutest_isinstance_works(((u>/Users/spulec/Development/freezegun/tests/test_class_import.pyus   freezegun-0.3.5/tests/__pycache__/test_datetimes.cpython-27-PYTEST.pyc0000644000076500000240000015642412464570012026210 0ustar spulecstaff00000000000000ó ðÒTQ2c@swddlZddljjZddlZddlZddlZddl Z ddl m Z ddl m Z ddlmZddlmZmZdefd„ƒYZdd d gZd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zdefd„ƒYZd„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%edƒd„ƒZ&d„Z'edƒdefd „ƒYƒZ(ed!ƒd"„ƒZ)d#„Z*d$„Z+d%„Z,d&„Z-ed!ƒd'„ƒZ.d(„Z/ed)ƒd*ej0fd+„ƒYƒZ1ed)ƒd,ej0fd-„ƒYƒZ2d.„Z3d/„Z4ed0ƒd1„ƒZ5ed2ƒd3„ƒZ6dS(4iÿÿÿÿN(tskip(tutils(t freeze_time(t FakeDatetimetFakeDatet temp_localecBs)eZdZd„Zd„Zd„ZRS(sTemporarily change the locale.cGs ||_dS(N(ttargets(tselfR((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt__init__scCs„tjtjƒ|_xC|jD]8}ytjtj|ƒdSWqtjk rVqXqWddj|jƒ}tj|ƒ‚dS(Ns"could not set locale to any of: %ss, ( tlocalet setlocaletLC_ALLtoldRtErrortjoinRtSkipTest(Rttargettmsg((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt __enter__scGstjtj|jƒdS(N(R R R R (Rtargs((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt__exit__s(t__name__t __module__t__doc__RRR(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR s  s da_DK.UTF-8s de_DE.UTF-8s fr_FR.UTF-8cCs»tdƒ}tjdddƒ}|tjdtjƒ}tj|jƒƒ}|jƒtj}|ƒ}||k}| rdtj df|fdf||fƒidt j ƒkpÃtj tƒrÕtj tƒndd 6tj |ƒd 6tj |ƒd 6d t j ƒkptj |ƒr,tj |ƒnd d 6}ddi|d6}ttj|ƒƒ‚nt}}}tj}|j}|ƒ}tj} d} d} d} | | | | ƒ} || k}| rtj df|fdf|| fƒi dt j ƒkptj tƒr$tj tƒndd6tj | ƒd6dt j ƒkpYtj tƒrktj tƒndd 6tj | ƒd6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj | ƒd6tj | ƒd6tj | ƒd6}ddi|d6}ttj|ƒƒ‚nt}}}}} } } } } tj}|j}|ƒ}tj} d} d} d} | | | | ƒ} || k}| rÚtj df|fdf|| fƒi dt j ƒkpÙtj tƒrëtj tƒndd6tj | ƒd6dt j ƒkp tj tƒr2tj tƒndd 6tj | ƒd6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj | ƒd6tj | ƒd6tj | ƒd6}ddi|d6}ttj|ƒƒ‚nt}}}}} } } } } tj}|j}|ƒ}tj} d} d} d} | | | | ƒ} || k}| r¡tj df|fdf|| fƒi dt j ƒkp tj tƒr²tj tƒndd6tj | ƒd6dt j ƒkpçtj tƒrùtj tƒndd 6tj | ƒd6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj | ƒd6tj | ƒd6tj | ƒd6}ddi|d6}ttj|ƒƒ‚nt}}}}} } } } } tj}|j}|ƒ}|j}|ƒ} tj} d} d} d}| | | |ƒ}| |k} | rštj df| fdf| |fƒi tj |ƒd6tj | ƒd6dt j ƒkp™tj tƒr«tj tƒndd 6tj | ƒd6tj |ƒd 6tj |ƒd 6tj |ƒd6tj |ƒd 6tj |ƒd6dt j ƒkp0tj tƒrBtj tƒndd6tj | ƒd6tj | ƒd6}ddi|d6}ttj|ƒƒ‚nt}}}}} } } } } }}|jƒtj}|ƒ}||k}| rÝ tj d f|fd!f||fƒidt j ƒkp< tj tƒrN tj tƒndd 6tj |ƒd 6tj |ƒd 6d t j ƒkp“ tj |ƒr¥ tj |ƒnd d 6}ddi|d6}ttj|ƒƒ‚nt}}}tj}|j}|ƒ}tj} d} d} d} | | | | ƒ} || k}| rŒ tj d f|fd"f|| fƒi dt j ƒkp‹ tj tƒr tj tƒndd6tj | ƒd6dt j ƒkpÒ tj tƒrä tj tƒndd 6tj | ƒd6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj | ƒd6tj | ƒd6tj | ƒd6}ddi|d6}ttj|ƒƒ‚nt}}}}} } } } } tj}|j}|ƒ}tj} d} d} d} | | | | ƒ} || k}| rS tj d f|fd#f|| fƒi dt j ƒkpR tj tƒrd tj tƒndd6tj | ƒd6dt j ƒkp™ tj tƒr« tj tƒndd 6tj | ƒd6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj | ƒd6tj | ƒd6tj | ƒd6}ddi|d6}ttj|ƒƒ‚nt}}}}} } } } } td$ƒ}|jƒtj}|j}|ƒ}tj} d} d} d%} d&} d'}d}| | | | | ||ƒ}||k}| r{tj df|fd(f||fƒi dt j ƒkpJtj tƒr\tj tƒndd6tj | ƒd6dt j ƒkp‘tj tƒr£tj tƒndd 6tj | ƒd6tj |ƒd 6tj |ƒd6tj |ƒd 6tj |ƒd6tj |ƒd 6tj |ƒd6tj | ƒd6tj | ƒd6tj | ƒd6}dd)i|d*6}ttj|ƒƒ‚nt}}}}} } } } } }}}|jƒdS(+Ns 2012-01-14iÜiitsecondss==sC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time }() } == %(py6)sttimetpy0tpy2tpy4texpected_timestamptpy6tsassert %(py8)stpy8sµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }tdatetimetpy18tpy16tpy12tpy14tpy10sassert %(py20)stpy20s¸%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.utcnow }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }s¯%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.date }.today }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.date }(%(py12)s, %(py14)s, %(py16)s) }sê%(py10)s {%(py10)s = %(py8)s {%(py8)s = %(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() }.today }() } == %(py22)s {%(py22)s = %(py14)s {%(py14)s = %(py12)s.datetime }(%(py16)s, %(py18)s, %(py20)s) }tpy22sassert %(py24)stpy24s!=sC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time }() } != %(py6)ssµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } != %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }s¸%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.utcnow }() } != %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }s2012-01-10 13:52:01i i i4sÓ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py24)s {%(py24)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s, %(py18)s, %(py20)s, %(py22)s) }sassert %(py26)stpy26(RR!t timedeltaRttimezonetmktimet timetupletstartt @pytest_art_call_reprcomparet @py_builtinstlocalst_should_repr_global_namet _safereprtAssertionErrort_format_explanationtNonetnowtutcnowtdatettodaytstop(tfreezert local_timetutc_timeRt @py_assert1t @py_assert3t @py_assert5t @py_format7t @py_format9t @py_assert9t @py_assert11t @py_assert13t @py_assert15t @py_assert17t @py_assert7t @py_format19t @py_format21t @py_assert19t @py_assert21t @py_format23t @py_format25t @py_assert23t @py_format27((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_simple_api&s   ¹  ÿ&  ÿ&  ÿ&  ÿ:.  ¹  ÿ&  ÿ&    ÿJ2cCsËtdddƒ}tjdddddd ƒ}|tjd tjƒ}tj|jƒƒ}|jƒtj}|j}|ƒ}tj}d}d} d } d } d} d } ||| | | | | ƒ}||k}| rTt j d f|fdf||fƒi dt j ƒkp#t j tƒr5t jtƒndd6t j| ƒd6dt j ƒkpjt j tƒr|t jtƒndd6t j| ƒd6t j|ƒd6t j|ƒd6t j|ƒd6t j| ƒd6t j|ƒd6t j| ƒd6t j|ƒd6t j| ƒd6t j|ƒd6}ddi|d6}tt j|ƒƒ‚nt}}}}}}} } } } } }tj}|j}|ƒ}tj}d}d} d} d} d} d } ||| | | | | ƒ}||k}| rrt j d f|fd f||fƒi dt j ƒkpAt j tƒrSt jtƒndd6t j| ƒd6dt j ƒkpˆt j tƒršt jtƒndd6t j| ƒd6t j|ƒd6t j|ƒd6t j|ƒd6t j| ƒd6t j|ƒd6t j| ƒd6t j|ƒd6t j| ƒd6t j|ƒd6}ddi|d6}tt j|ƒƒ‚nt}}}}}}} } } } } }tj}|ƒ}||k}| r¯t j d f|fd!f||fƒid"t j ƒkpt j tƒr t jtƒnd"d6t j|ƒd6t j|ƒd6d#t j ƒkpet j |ƒrwt j|ƒnd#d6}dd$i|d6}tt j|ƒƒ‚nt}}}|jƒdS(%Ns2012-01-14 03:21:34t tz_offsetiüÿÿÿiÜiiiii"Ri is==sÓ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py24)s {%(py24)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s, %(py18)s, %(py20)s, %(py22)s) }R!R R"RR#RR)RR(RR'R$R%R&Rsassert %(py26)sR*sÖ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.utcnow }() } == %(py24)s {%(py24)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s, %(py18)s, %(py20)s, %(py22)s) }sC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time }() } == %(py6)sRRsassert %(py8)s(RR!R+RR,R-R.R/R9R0R1R2R3R4R5R6R7R8R:R=(R>R?R@RRARBRCRFRGRHRIRJRNRORRRKRQRSRDRE((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_tz_offset>sd   ÿJ2  ÿJ2 ¹c Cs¸tdddƒ}|jƒtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | r½tjdf| fdf||fƒi d tjƒkp¼tj tƒrÎtj tƒnd d 6tj |ƒd 6d tjƒkptj tƒrtj tƒnd d 6tj |ƒd 6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}|jƒtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | rŽtjdf| fdf||fƒi d tjƒkptj tƒrŸtj tƒnd d 6tj |ƒd 6d tjƒkpÔtj tƒrætj tƒnd d 6tj |ƒd 6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}dS(Ns 2012-01-14RUiüÿÿÿiÜii s==s¯%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.date }.today }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.date }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR's!=s¯%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.date }.today }() } != %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.date }(%(py12)s, %(py14)s, %(py16)s) }(RR/R!R;R<R0R1R2R3R4R5R6R7R8R=( R>RARBRCRFRGRHRIRJRKRLRM((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_tz_offset_with_todayNsB   ÿ&   ÿcCsutdƒ}|jƒtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | r·tjdf| fdf||fƒi dtjƒkp¶tj tƒrÈtj tƒndd6tj |ƒd6dtjƒkpýtj tƒrtj tƒndd 6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}tj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | r~tjdf| fdf||fƒi dtjƒkp}tj tƒrtj tƒndd6tj |ƒd6dtjƒkpÄtj tƒrÖtj tƒndd 6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}tj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | rEtjdf| fdf||fƒi dtjƒkpDtj tƒrVtj tƒndd6tj |ƒd6dtjƒkp‹tj tƒrtj tƒndd 6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}tj}|ƒ}d} || k}| rUtjdf|fdf|| fƒidtjƒkpÛtj tƒrítj tƒndd 6tj |ƒd 6tj |ƒd 6tj | ƒd6} ddi| d6}t tj |ƒƒ‚nt }}}} |jƒdS(Ns 1970-01-01i²is==s¯%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.date }.today }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.date }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR'sµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }s¸%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.utcnow }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }gsC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time }() } == %(py7)sRtpy7sassert %(py9)stpy9(RR/R!R;R<R0R1R2R3R4R5R6R7R8R9R:RR=(R>RARBRCRFRGRHRIRJRKRLRMt @py_assert6t @py_format8t @py_format10((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_zero_tz_offset_with_timeVsr    ÿ&  ÿ&  ÿ&  ’cCs˜tdddƒ}|jƒtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | r½tjdf| fdf||fƒi d tjƒkp¼tj tƒrÎtj tƒnd d 6tj |ƒd 6d tjƒkptj tƒrtj tƒnd d 6tj |ƒd 6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}tj}|j}|ƒ}tj}d}d}d}d}|||||ƒ} || k} | rtjdf| fdf|| fƒi d tjƒkpŒtj tƒržtj tƒnd d 6tj |ƒd 6d tjƒkpÓtj tƒråtj tƒnd d 6tj |ƒd 6tj |ƒd6tj |ƒd6tj |ƒd6tj | ƒd6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}} tj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | rhtjdf| fdf||fƒi d tjƒkpgtj tƒrytj tƒnd d 6tj |ƒd 6d tjƒkp®tj tƒrÀtj tƒnd d 6tj |ƒd 6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}tj}|ƒ}d}||k}| rxtjdf|fdf||fƒid tjƒkpþtj tƒrtj tƒnd d 6tj |ƒd6tj |ƒd6tj |ƒd!6}dd"i|d#6}t tj |ƒƒ‚nt }}}}|jƒdS($Ns 1970-01-01RUiüÿÿÿi±i is==s¯%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.date }.today }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.date }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR'is¿%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py20)s {%(py20)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s, %(py18)s) }sassert %(py22)sR(i²is¸%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.utcnow }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }gsC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time }() } == %(py7)sRRXsassert %(py9)sRY(RR/R!R;R<R0R1R2R3R4R5R6R7R8R9R:RR=(R>RARBRCRFRGRHRIRJRKRLRMRNRPRZR[R\((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_tz_offset_with_timebst   ÿ&  ÿ**  ÿ&  ’c Cs0ttjdddddddƒƒ}|jƒtj}|ƒ}d}||k}|stjd|fd||fƒidtjƒkstjtƒr¬tj tƒndd 6tj |ƒd 6tj |ƒd 6tj |ƒd 6}di|d6}t tj |ƒƒ‚nd}}}}|j ƒdS(Ni²iii@âglë§ÿ¬ùñ?s==sC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time }() } == %(py7)sRRRRRXRsassert %(py9)sRY(s==(sC%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time }() } == %(py7)ssassert %(py9)s(RR!R/RR0R1R2R3R4R5R6R7R8R=(R>RARBRZRCR[R\((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_time_with_microsecondsns'   ŒcCs˜ytdddƒWntk r'nmXts”tjdƒdidtjƒksbtjtƒrqtjtƒndd6}t tj |ƒƒ‚ndS(Ns 2012-13-14RUiüÿÿÿs$Bad values should raise a ValueErrors >assert %(py0)stFalseR( Rt ValueErrorR`R0t_format_assertmsgR2R3R4R5R6R7(t @py_format1((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_bad_time_argumentus Nc Cs—tdƒ…tjƒ}|j}d}||k}|sßtjd|fd||fƒidtjƒks|tj|ƒr‹tj |ƒndd6tj |ƒd6tj |ƒd6}di|d 6}t tj |ƒƒ‚nd}}}|j }d }||k}|s³tjd|fd||fƒidtjƒksPtj|ƒr_tj |ƒndd6tj |ƒd6tj |ƒd6}d i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|s‡tjd!|fd"||fƒidtjƒks$tj|ƒr3tj |ƒndd6tj |ƒd6tj |ƒd6}d#i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|s[tjd$|fd%||fƒidtjƒksøtj|ƒrtj |ƒndd6tj |ƒd6tj |ƒd6}d&i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|s/tjd'|fd(||fƒidtjƒksÌtj|ƒrÛtj |ƒndd6tj |ƒd6tj |ƒd6}d)i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|stjd*|fd+||fƒidtjƒks tj|ƒr¯tj |ƒndd6tj |ƒd6tj |ƒd6}d,i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|s×tjd-|fd.||fƒidtjƒksttj|ƒrƒtj |ƒndd6tj |ƒd6tj |ƒd6}d/i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|s«tjd0|fd1||fƒidtjƒksHtj|ƒrWtj |ƒndd6tj |ƒd6tj |ƒd6}d2i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|stjd3|fd4||fƒidtjƒkstj|ƒr+tj |ƒndd6tj |ƒd6tj |ƒd6}d5i|d 6}t tj |ƒƒ‚nd}}}WdQXdS(6Ns2012-01-14 03:21:34iÜs==s/%(py2)s {%(py2)s = %(py0)s.tm_year } == %(py5)st time_structRRtpy5Rsassert %(py7)sRXis.%(py2)s {%(py2)s = %(py0)s.tm_mon } == %(py5)sis/%(py2)s {%(py2)s = %(py0)s.tm_mday } == %(py5)sis/%(py2)s {%(py2)s = %(py0)s.tm_hour } == %(py5)sis.%(py2)s {%(py2)s = %(py0)s.tm_min } == %(py5)si"s.%(py2)s {%(py2)s = %(py0)s.tm_sec } == %(py5)sis/%(py2)s {%(py2)s = %(py0)s.tm_wday } == %(py5)ss/%(py2)s {%(py2)s = %(py0)s.tm_yday } == %(py5)siÿÿÿÿs0%(py2)s {%(py2)s = %(py0)s.tm_isdst } == %(py5)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_year } == %(py5)ssassert %(py7)s(s==(s.%(py2)s {%(py2)s = %(py0)s.tm_mon } == %(py5)ssassert %(py7)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_mday } == %(py5)ssassert %(py7)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_hour } == %(py5)ssassert %(py7)s(s==(s.%(py2)s {%(py2)s = %(py0)s.tm_min } == %(py5)ssassert %(py7)s(s==(s.%(py2)s {%(py2)s = %(py0)s.tm_sec } == %(py5)ssassert %(py7)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_wday } == %(py5)ssassert %(py7)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_yday } == %(py5)ssassert %(py7)s(s==(s0%(py2)s {%(py2)s = %(py0)s.tm_isdst } == %(py5)ssassert %(py7)s(RRtgmtimettm_yearR0R1R2R3R4R5R6R7R8ttm_monttm_mdayttm_hourttm_minttm_secttm_wdayttm_ydayttm_isdst(ReRAt @py_assert4RBt @py_format6R[((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_time_gmtime~s”    |  |  |  |  |  |  |  |  |tmodify_timezonecBs#eZd„Zd„Zd„ZRS(cCs||_tj|_dS(N(t new_timezoneRR,toriginal_timezone(RRu((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRŽs cCs|jt_dS(N(RuRR,(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR’scGs|jt_dS(N(RvRR,(RR((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR•s(RRRRR(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRtŒs  cCsªtdƒ˜tdƒ…tjƒ}|j}d}||k}|sìtjd|fd||fƒidtjƒks‰tj |ƒr˜tj |ƒndd6tj |ƒd6tj |ƒd 6}di|d 6}t tj |ƒƒ‚nd}}}|j}d }||k}|sÀtjd|fd ||fƒidtjƒks]tj |ƒrltj |ƒndd6tj |ƒd6tj |ƒd 6}d!i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|s”tjd"|fd#||fƒidtjƒks1tj |ƒr@tj |ƒndd6tj |ƒd6tj |ƒd 6}d$i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|shtjd%|fd&||fƒidtjƒkstj |ƒrtj |ƒndd6tj |ƒd6tj |ƒd 6}d'i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|s<tjd(|fd)||fƒidtjƒksÙtj |ƒrètj |ƒndd6tj |ƒd6tj |ƒd 6}d*i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|stjd+|fd,||fƒidtjƒks­tj |ƒr¼tj |ƒndd6tj |ƒd6tj |ƒd 6}d-i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|sätjd.|fd/||fƒidtjƒkstj |ƒrtj |ƒndd6tj |ƒd6tj |ƒd 6}d0i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|s¸tjd1|fd2||fƒidtjƒksUtj |ƒrdtj |ƒndd6tj |ƒd6tj |ƒd 6}d3i|d 6}t tj |ƒƒ‚nd}}}|j}d}||k}|sŒtjd4|fd5||fƒidtjƒks)tj |ƒr8tj |ƒndd6tj |ƒd6tj |ƒd 6}d6i|d 6}t tj |ƒƒ‚nd}}}WdQXWdQXdS(7Niðñÿÿs2012-01-14 03:21:34iÜs==s/%(py2)s {%(py2)s = %(py0)s.tm_year } == %(py5)sReRRRfRsassert %(py7)sRXis.%(py2)s {%(py2)s = %(py0)s.tm_mon } == %(py5)sis/%(py2)s {%(py2)s = %(py0)s.tm_mday } == %(py5)sis/%(py2)s {%(py2)s = %(py0)s.tm_hour } == %(py5)sis.%(py2)s {%(py2)s = %(py0)s.tm_min } == %(py5)si"s.%(py2)s {%(py2)s = %(py0)s.tm_sec } == %(py5)sis/%(py2)s {%(py2)s = %(py0)s.tm_wday } == %(py5)ss/%(py2)s {%(py2)s = %(py0)s.tm_yday } == %(py5)siÿÿÿÿs0%(py2)s {%(py2)s = %(py0)s.tm_isdst } == %(py5)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_year } == %(py5)ssassert %(py7)s(s==(s.%(py2)s {%(py2)s = %(py0)s.tm_mon } == %(py5)ssassert %(py7)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_mday } == %(py5)ssassert %(py7)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_hour } == %(py5)ssassert %(py7)s(s==(s.%(py2)s {%(py2)s = %(py0)s.tm_min } == %(py5)ssassert %(py7)s(s==(s.%(py2)s {%(py2)s = %(py0)s.tm_sec } == %(py5)ssassert %(py7)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_wday } == %(py5)ssassert %(py7)s(s==(s/%(py2)s {%(py2)s = %(py0)s.tm_yday } == %(py5)ssassert %(py7)s(s==(s0%(py2)s {%(py2)s = %(py0)s.tm_isdst } == %(py5)ssassert %(py7)s(RtRRt localtimeRhR0R1R2R3R4R5R6R7R8RiRjRkRlRmRnRoRp(ReRARqRBRrR[((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_time_localtime™s–     |  |  |  |  |  |  |  |  |cCs8tdƒ&tdƒtj}d}||ƒ}d}||k}|stjd|fd||fƒidtjƒkstjtƒržtj tƒndd6tj |ƒd 6tj |ƒd 6tj |ƒd 6tj |ƒd 6}di|d6}t tj |ƒƒ‚nd}}}}}WdQXWdQXdS(Nis 1970-01-01s%Yt1970s==sN%(py6)s {%(py6)s = %(py2)s {%(py2)s = %(py0)s.strftime }(%(py4)s) } == %(py9)sRRRYRRRRsassert %(py11)stpy11(s==(sN%(py6)s {%(py6)s = %(py2)s {%(py2)s = %(py0)s.strftime }(%(py4)s) } == %(py9)ssassert %(py11)s( RtRRtstrftimeR0R1R2R3R4R5R6R7R8(RARBRCt @py_assert8RKR\t @py_format12((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt test_strftime¨s     œcCsHtjddddddƒ}t|ƒ}tdƒ}|j}|j}||k}|s6tjd|fd||fƒid tjƒksœtj|ƒr«tj |ƒnd d 6tj |ƒd 6d tjƒksãtj|ƒròtj |ƒnd d6tj |ƒd6}di|d6}t tj |ƒƒ‚nd}}}dS(NtyeariÜtmonthi tdayi s 2012-11-10s==sZ%(py2)s {%(py2)s = %(py0)s.time_to_freeze } == %(py6)s {%(py6)s = %(py4)s.time_to_freeze }t date_freezerRRtregular_freezerRRRsassert %(py8)sR (s==(sZ%(py2)s {%(py2)s = %(py0)s.time_to_freeze } == %(py6)s {%(py6)s = %(py4)s.time_to_freeze }sassert %(py8)s( R!R;Rttime_to_freezeR0R1R2R3R4R5R6R7R8(t frozen_dateR‚RƒRARCRBRDRE((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_date_object®s   ³c CslttŒZtjddddddƒ}t|ƒ}|j}|j}|ƒ}||k}|sPtjd|fd||fƒid tj ƒks¦tj |ƒrµtj |ƒnd d 6d tj ƒksÝtj |ƒrìtj |ƒnd d 6tj |ƒd 6tj |ƒd6tj |ƒd6}di|d6}t tj |ƒƒ‚nd}}}}WdQXdS(NRiÜR€iRis==sg%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time_to_freeze }.date }() } == %(py8)sR‚RR…R RRRRsassert %(py10)sR&(s==(sg%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.time_to_freeze }.date }() } == %(py8)ssassert %(py10)s(Rt_dd_mm_yyyy_localesR!R;RR„R0R1R2R3R4R5R6R7R8(R…R‚RARBRCRKREt @py_format11((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_date_with_locale´s   ÃcCs˜yttdƒƒWntk r'nmXts”tjdƒdidtjƒksbtjtƒrqtj tƒndd6}t tj |ƒƒ‚ndS(Nis"Bad types should raise a TypeErrors >assert %(py0)sR`R( Rtintt TypeErrorR`R0RbR2R3R4R5R6R7(Rc((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_invalid_typeºs Nc CsZtjddddddddd d d d ƒ}t|ƒ}td ƒ}|j}|j}||k}|sHtjd|fd||fƒidtjƒks®tj|ƒr½tj|ƒndd6tj|ƒd6dtjƒksõtj|ƒrtj|ƒndd6tj|ƒd6}di|d6}t tj |ƒƒ‚nd}}}dS(NRiÜR€i Ri thouritminuteitsecondis2012-11-10 04:15:30s==sZ%(py2)s {%(py2)s = %(py0)s.time_to_freeze } == %(py6)s {%(py6)s = %(py4)s.time_to_freeze }tdatetime_freezerRRRƒRRRsassert %(py8)sR (s==(sZ%(py2)s {%(py2)s = %(py0)s.time_to_freeze } == %(py6)s {%(py6)s = %(py4)s.time_to_freeze }sassert %(py8)s( R!RR„R0R1R2R3R4R5R6R7R8(tfrozen_datetimeRRƒRARCRBRDRE((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_datetime_objectÃs   ³c Cs2ttŒ tjddddddƒ}t|ƒ}|j}||k}|stjd|fd||fƒid tjƒks”tj |ƒr£tj |ƒnd d 6tj |ƒd 6d tjƒksÛtj |ƒrêtj |ƒnd d 6}di|d6}t tj |ƒƒ‚nd}}WdQXdS(NRiÜR€iRis==s6%(py2)s {%(py2)s = %(py0)s.time_to_freeze } == %(py4)sR‚RRR‘RRsassert %(py6)sR(s==(s6%(py2)s {%(py2)s = %(py0)s.time_to_freeze } == %(py4)ssassert %(py6)s(RR‡R!RR„R0R1R2R3R4R5R6R7R8(R‘R‚RARBt @py_format5RD((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_datetime_with_localeÊs   £s 2012-01-14c CsËtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k}| r¡tjdf|fdf||fƒi dtjƒkp tjtƒr²tjtƒndd6tj|ƒd6dtjƒkpçtjtƒrùtjtƒndd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} ttj | ƒƒ‚nt }}}}}}}}}dS(NiÜiis==sµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR'( R!R9R0R1R2R3R4R5R6R7R8( RARBRCRFRGRHRIRJRKRLRM((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_decoratorÐs  ÿcCsd„}tdƒ|ƒ}|j}||k}|stjd |fd||fƒidtjƒksxtj|ƒr‡tj|ƒndd6tj|ƒd6dtjƒks¿tj|ƒrÎtj|ƒndd 6}di|d 6}ttj |ƒƒ‚nd}}dS(NcSsdS(N((((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt to_decorateÖss 2014-01-14tiss3%(py2)s {%(py2)s = %(py0)s.__wrapped__ } is %(py4)stwrappedRRR–RRsassert %(py6)sR(R—(s3%(py2)s {%(py2)s = %(py0)s.__wrapped__ } is %(py4)ssassert %(py6)s( Rt __wrapped__R0R1R2R3R4R5R6R7R8(R–R˜RARBR“RD((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt test_decorator_wrapped_attributeÕs  £tTestercBseZd„Zd„ZRS(c CsËtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | r¡tjdf| fdf||fƒi dtjƒkp tjtƒr²tjtƒndd6tj|ƒd6dtjƒkpçtjtƒrùtjtƒndd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} ttj | ƒƒ‚nt }}}} }}}}}dS(NiÜiis==sµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR'( R!R9R0R1R2R3R4R5R6R7R8( RRARBRCRFRGRHRIRJRKRLRM((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_the_classßs  ÿc CsËtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k} | r¡tjdf| fdf||fƒi dtjƒkp tjtƒr²tjtƒndd6tj|ƒd6dtjƒkpçtjtƒrùtjtƒndd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} ttj | ƒƒ‚nt }}}} }}}}}dS(NiÜiis==sµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR'( R!R9R0R1R2R3R4R5R6R7R8( RRARBRCRFRGRHRIRJRKRLRM((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_still_the_sameâs  ÿ(RRRœR(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR›Ýs sJan 14th, 2012c CsËtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k}| r¡tjdf|fdf||fƒi dtjƒkp tjtƒr²tjtƒndd6tj|ƒd6dtjƒkpçtjtƒrùtjtƒndd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} ttj | ƒƒ‚nt }}}}}}}}}dS(NiÜiis==sµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR'( R!R9R0R1R2R3R4R5R6R7R8( RARBRCRFRGRHRIRJRKRLRM((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_nice_datetimeæs  ÿc Cs¥tdƒÌtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k}| r®tjdf|fdf||fƒi dtjƒkp­tjtƒr¿tjtƒndd6tj|ƒd 6dtjƒkpôtjtƒrtjtƒndd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}}}}}}}WdQXtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k}| r{tjdf|fdf||fƒi dtjƒkpztjtƒrŒtjtƒndd6tj|ƒd 6dtjƒkpÁtjtƒrÓtjtƒndd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}}}}}}}dS(Ns 2012-01-14iÜiis==sµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR's!=sµ%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } != %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }( RR!R9R0R1R2R3R4R5R6R7R8( RARBRCRFRGRHRIRJRKRLRM((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_context_managerës>   ÿ,  ÿc Cs#tdƒJtdƒttjdddƒƒWdQXttjdddƒƒWdQXtj}|j}|ƒ}tj}d}d}d}||||ƒ}||k}| rùtjd f|fd f||fƒi d tjƒkpøtjtƒr tj tƒnd d 6tj |ƒd 6d tjƒkp?tjtƒrQtj tƒnd d6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6tj |ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}}}}}}}dS(Ns 2012-01-14s 2012-12-25iÜi iiiiÝt>s´%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } > %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }R!R R"RR#RRRR$R%R&Rsassert %(py20)sR'( Rt,_assert_datetime_date_and_time_are_all_equalR!R9R0R1R2R3R4R5R6R7R8( RARBRCRFRGRHRIRJRKRLRM((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_nested_context_managerñs&    ÿcCs™tj}|j}|ƒ}||k}|stjd|fd||fƒidtjƒksotjtƒr~tjtƒndd6dtjƒks¦tj|ƒrµtj|ƒndd6tj|ƒd6tj|ƒd6tj|ƒd 6}di|d 6}ttj |ƒƒ‚nd}}}}tj }|j }|ƒ}|j }|ƒ}||k}|svtjd|fd||fƒidtjƒks¬tj|ƒr»tj|ƒndd6dtjƒksãtjtƒròtjtƒndd6tj|ƒd6tj|ƒd6tj|ƒd 6tj|ƒd6tj|ƒd 6} di| d6} ttj | ƒƒ‚nd}}}}}}tjj tjƒƒ} | tjdtjƒ} | |k}|stjd|fd| |fƒidtjƒkstj| ƒr$tj| ƒndd6dtjƒksLtj|ƒr[tj|ƒndd6} di| d6}ttj |ƒƒ‚nd}dS(Ns==s`%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py8)sR!Rtexpected_datetimeR RRRRsassert %(py10)sR&s“%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.date }.today }() } == %(py12)s {%(py12)s = %(py10)s {%(py10)s = %(py8)s.date }() }R$sassert %(py14)sR%Rs%(py0)s == %(py2)sttimezone_adjusted_datetimesassert %(py4)s(s==(s`%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py8)ssassert %(py10)s(s==(s“%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.date }.today }() } == %(py12)s {%(py12)s = %(py10)s {%(py10)s = %(py8)s.date }() }sassert %(py14)s(s==(s%(py0)s == %(py2)ssassert %(py4)s(R!R9R0R1R2R3R4R5R6R7R8R;R<t fromtimestampRR+R,(R£RARBRCRKRERˆRFRGt @py_format13t @py_format15tdatetime_from_timeR¤t @py_format3R“((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR¡ùs8 à 㠓c CsS tdddƒttdddƒ°tj}|j}|ƒ}tj}d}d}d}d }|||||ƒ}||k} | ràtjd f| fd f||fƒi d tjƒkpÏtjtƒrátjtƒnd d 6tj|ƒd6d tjƒkptjtƒr(tjtƒnd d6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}}tj }|j }|ƒ}tj }d}d}d}||||ƒ}||k} | r«tjd f| fdf||fƒi d tjƒkpªtjtƒr¼tjtƒnd d 6tj|ƒd6d tjƒkpñtjtƒrtjtƒnd d6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}WdQXtj}|j}|ƒ}tj}d}d }d}d }|||||ƒ}||k} | r‘tjd f| fd f||fƒi d tjƒkp€tjtƒr’tjtƒnd d 6tj|ƒd6d tjƒkpÇtjtƒrÙtjtƒnd d6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}}tj }|j }|ƒ}tj }d}d }d}||||ƒ}||k} | r\tjd f| fdf||fƒi d tjƒkp[tjtƒrmtjtƒnd d 6tj|ƒd6d tjƒkp¢tjtƒr´tjtƒnd d6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}WdQXtj}|j}|ƒ}tj}d}d }d }||||ƒ}||k} | r) tjdf| fd f||fƒi d tjƒkp(tjtƒr:tjtƒnd d 6tj|ƒd6d tjƒkpotjtƒrtjtƒnd d6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6tj|ƒd6} ddi| d6} t tj | ƒƒ‚nt }}}} }}}}}dS(!Ns2012-01-14 23:00:00RUis2012-12-25 19:00:00iiÜi iis==s¿%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } == %(py20)s {%(py20)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s, %(py18)s) }R!R R"RR#RRRR'R$R%R&Rsassert %(py22)sR(s¯%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.date }.today }() } == %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.date }(%(py12)s, %(py14)s, %(py16)s) }sassert %(py20)siiÝR s´%(py6)s {%(py6)s = %(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.datetime }.now }() } > %(py18)s {%(py18)s = %(py10)s {%(py10)s = %(py8)s.datetime }(%(py12)s, %(py14)s, %(py16)s) }(RR!R9R0R1R2R3R4R5R6R7R8R;R<( RARBRCRFRGRHRIRJRNRKRMRPRL((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt+test_nested_context_manager_with_tz_offsetssž  ÿ**  ÿ,  ÿ**  ÿ,  ÿcCsÔtjjƒ}tj}||ƒ}|sÞddidtjƒksUtjtƒrdtjtƒndd6tj|ƒd6dtjƒksœtj|ƒr«tj|ƒndd6tj|ƒd6}t tj |ƒƒ‚nd}}tj j ƒ}tj}||ƒ}|sÆdd idtjƒks=tjtƒrLtjtƒndd6tj|ƒd6d tjƒks„tj|ƒr“tj|ƒnd d6tj|ƒd6}t tj |ƒƒ‚nd}}dS( NRsRassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_datetime }(%(py3)s) }RRRR9tpy3RfsNassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_date }(%(py3)s) }R<(R!R9Rtis_fake_datetimeR2R3R0R4R5R6R7R8R;R<t is_fake_date(R9RARqRrR<((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_isinstance_with_active s œ  œcCs[tjjƒ}tj}t||ƒ}|sddidtjƒksXtjtƒrgtjtƒndd6dtjƒkstj|ƒržtj|ƒndd6dtjƒksÆtjtƒrÕtjtƒndd6tj|ƒd 6tj|ƒd 6}ttj |ƒƒ‚nd}}tj }t||ƒ}|s+dd idtjƒksktjtƒrztjtƒndd6dtjƒks¢tj|ƒr±tj|ƒndd6dtjƒksÙtjtƒrètjtƒndd6tj|ƒd 6tj|ƒd 6}ttj |ƒƒ‚nd}}tj j ƒ}tj }t||ƒ}|sMdd idtjƒkstjtƒrœtjtƒndd6d tjƒksÄtj|ƒrÓtj|ƒnd d6dtjƒksûtjtƒr tjtƒndd6tj|ƒd 6tj|ƒd 6}ttj |ƒƒ‚nd}}dS( NRsSassert %(py6)s {%(py6)s = %(py0)s(%(py1)s, %(py4)s {%(py4)s = %(py2)s.datetime }) }t isinstanceRR9tpy1R!RRRsOassert %(py6)s {%(py6)s = %(py0)s(%(py1)s, %(py4)s {%(py4)s = %(py2)s.date }) }R<( R!R9R¯R2R3R0R4R5R6R7R8R;R<(R9RBRCRDR<((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_isinstance_without_actives( Ó  Ó  Ós 2013-04-09tTestUnitTestClassDecoratorcBs)eZd„Zed„ƒZd„ZRS(cCs,|jtjdddƒtjjƒƒdS(NiÝii (t assertEqualR!R;R<(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pytsetUpscCs,tjdddƒjjtjjƒƒdS(NiÝii (R!R;tshouldnttequalR<(tcls((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt setUpClass"scCs,|jtjdddƒtjjƒƒdS(NiÝii (R³R!R;R<(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt&test_class_decorator_works_on_unittest&s(RRR´t classmethodR¸R¹(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR²s t#TestUnitTestClassDecoratorWithSetupcBseZd„Zd„ZRS(cCsdS(N((R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR´+scCs,|jtjdddƒtjjƒƒdS(NiÝii (R³R!R;R<(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR¹.s(RRR´R¹(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR»)s cCsÌtjjjjj|ƒtjjjjj|ƒtjjjjj|ƒtjjjjj|ƒtjjjjj|ƒtjjjjj|ƒtjjjjj|ƒtjjjjj|ƒdS(N(R!tmint __class__tshouldR¶tmaxR;Rµ(t right_classt wrong_class((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pytassert_class_of_datetimes2scCsÒtdƒ}tj}tj}|jƒtjjjjjtƒtjj jjjtƒtjjjjjt ƒtjj jjjt ƒtjjjj j|ƒtjj jj j|ƒtjjjj j|ƒtjj jj j|ƒ|j ƒtjjjjjtjƒtjj jjjtjƒtjjjjjtjƒtjj jjjtjƒtjjjj jtƒtjj jj jtƒtjjjj jt ƒtjj jj jt ƒdS(Ns 2012-01-14( RR!R;R/R¼R½R¾R¶RR¿RRµR=(R>t real_datetimet real_date((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_min_and_max=s*     s2014-07-30T01:00:00ZcCstjjƒ}|j}|d k}|sötjd |fd |d fƒidtjƒksltj|ƒr{tj |ƒndd6tj |ƒd6dtjƒks³tjd ƒrÂtj d ƒndd6}di|d 6}t tj |ƒƒ‚nd }}d S(sA utcnow() should always return a timezone naive datetime s==s.%(py2)s {%(py2)s = %(py0)s.tzinfo } == %(py4)stutc_nowRRR8RRsassert %(py6)sRN(s==(s.%(py2)s {%(py2)s = %(py0)s.tzinfo } == %(py4)ssassert %(py6)s( R!R:ttzinfoR8R0R1R2R3R4R5R6R7(RÆRARBR“RD((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt/test_freeze_with_timezone_aware_datetime_in_utcWs £s1970-01-01T00:00:00-04:00c Cs†tjjƒ}|j}|dk}|sötjd|fd|dfƒidtjƒksltj|ƒr{tj |ƒndd6tj |ƒd6dtjƒks³tjdƒrÂtj dƒndd6}di|d 6}t tj |ƒƒ‚nd}}tj}d }d }d }d }|||||ƒ} || k}|sdtjd|fd|| fƒitj |ƒd6dtjƒksštj|ƒr©tj |ƒndd6dtjƒksÑtjtƒràtj tƒndd6tj |ƒd6tj |ƒd 6tj |ƒd6tj | ƒd6tj |ƒd6} di| d6} t tj | ƒƒ‚nd}}}}}}} dS(sŽ we expect the system to behave like a system with UTC-4 timezone at the beginning of the Epoch (wall clock should be 4 hrs late) s==s.%(py2)s {%(py2)s = %(py0)s.tzinfo } == %(py4)sRÆRRR8RRsassert %(py6)sRi²iism%(py0)s == %(py14)s {%(py14)s = %(py4)s {%(py4)s = %(py2)s.datetime }(%(py6)s, %(py8)s, %(py10)s, %(py12)s) }R R!R$R%R&sassert %(py16)sR#N(s==(s.%(py2)s {%(py2)s = %(py0)s.tzinfo } == %(py4)ssassert %(py6)s(s==(sm%(py0)s == %(py14)s {%(py14)s = %(py4)s {%(py4)s = %(py2)s.datetime }(%(py6)s, %(py8)s, %(py10)s, %(py12)s) }sassert %(py16)s( R!R:RÇR8R0R1R2R3R4R5R6R7( RÆRARBR“RDRCRKRFRGRHR§t @py_format17((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt3test_freeze_with_timezone_aware_datetime_in_non_utc`s( £   ó(7t __builtin__R2t_pytest.assertion.rewritet assertiontrewriteR0RR!tunittestR t nose.pluginsRttestsRt freezegunRt freezegun.apiRRtobjectRR‡RTRVRWR]R^R_RdRsRtRxR~R†R‰RŒR’R”R•RšR›RžRŸR¢R¡RªR®R±tTestCaseR²R»RÂRÅRÈRÊ(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyts\                           freezegun-0.3.5/tests/__pycache__/test_datetimes.cpython-33.pyc0000644000076500000240000001702712161103373025146 0ustar spulecstaff00000000000000ž ±Ð¿QSc@s'ddlZddlZddlmZdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z edƒdd„ƒZ edƒGdd„de ƒƒZ edƒdd„ƒZdd„Zedƒdd„ƒZdd„ZedƒGd d!„d!ejƒƒZdS("iN(u freeze_timecCsytdƒ}|jƒtjjƒtjdddƒks@t‚tjjƒtjdddƒksjt‚tjjƒtjdddƒks”t‚tjjƒjƒtjdddƒksÄt‚|jƒtjjƒtjdddƒksøt‚tjjƒtjdddƒks"t‚tdƒ}|jƒtjjƒtjddddddƒkskt‚|jƒdS( Nu 2012-01-14iÜiiu2012-01-10 13:52:01i i i4( u freeze_timeustartudatetimeunowuAssertionErroruutcnowudateutodayustop(ufreezer((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_simple_apis  ***0 **  3utest_simple_apicCstddd ƒ}|jƒtjjƒtjdddddd ƒksOt‚tjjƒtjddd d dd ƒks‚t‚|jƒdS( Nu2012-01-14 03:21:34u tz_offsetiiÜii iii"iiiüÿÿÿ(u freeze_timeustartudatetimeunowuAssertionErroruutcnowustop(ufreezer((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_tz_offsets  33utest_tz_offsetcCs~tdddƒ}|jƒtjjƒtjdddƒksFt‚|jƒtjjƒtjdddƒkszt‚dS(Nu 2012-01-14u tz_offsetiiÜii iüÿÿÿ(u freeze_timeustartudatetimeudateutodayuAssertionErrorustop(ufreezer((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_tz_offset_with_todays  * utest_tz_offset_with_todayc Cs?ytdddƒWntk r(YnXds;tdƒ‚dS(Nu 2012-13-14u tz_offsetiu$Bad values should raise a ValueErroriüÿÿÿF(u freeze_timeu ValueErroruFalseuAssertionError(((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_bad_time_argument's  utest_bad_time_argumentcCsRtjddddddƒ}t|ƒ}tdƒ}|j|jksNt‚dS(NuyeariÜumonthi udayi u 2012-11-10(udatetimeudateu freeze_timeutime_to_freezeuAssertionError(u frozen_dateu date_freezeruregular_freezer((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_date_object0s  utest_date_objectc Cs?yttdƒƒWntk r(YnXds;tdƒ‚dS(Niu"Bad types should raise a TypeErrorF(u freeze_timeuintu TypeErroruFalseuAssertionError(((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_invalid_type7s  utest_invalid_typec Csdtjddddddddd d d d ƒ}t|ƒ}td ƒ}|j|jks`t‚dS(NuyeariÜumonthi udayi uhouriuminuteiusecondiu2012-11-10 04:15:30(udatetimeu freeze_timeutime_to_freezeuAssertionError(ufrozen_datetimeudatetime_freezeruregular_freezer((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_datetime_object@s   utest_datetime_objectu 2012-01-14cCs.tjjƒtjdddƒks*t‚dS(NiÜii(udatetimeunowuAssertionError(((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_decoratorHsutest_decoratorcBs,|EeZdZdd„Zdd„ZdS(uTestercCs.tjjƒtjdddƒks*t‚dS(NiÜii(udatetimeunowuAssertionError(uself((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_the_classOsuTester.test_the_classcCs.tjjƒtjdddƒks*t‚dS(NiÜii(udatetimeunowuAssertionError(uself((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_still_the_sameRsuTester.test_still_the_sameN(u__name__u __module__u __qualname__utest_the_classutest_still_the_same(u __locals__((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyuTesterMs uTesteruJan 14th, 2012cCs.tjjƒtjdddƒks*t‚dS(NiÜii(udatetimeunowuAssertionError(((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_nice_datetimeVsutest_nice_datetimec Csktdƒ/tjjƒtjdddƒks7t‚WdQXtjjƒtjdddƒksgt‚dS(Nu 2012-01-14iÜii(u freeze_timeudatetimeunowuAssertionError(((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_context_manager[s 0utest_context_managercCsRtjjƒ}t|tjƒs't‚tjjƒ}t|tjƒsNt‚dS(N(udatetimeunowu isinstanceuAssertionErrorudateutoday(unowutoday((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_isinstance_with_activeasutest_isinstance_with_activecCsjtjjƒ}t|tjƒs't‚t|tjƒs?t‚tjjƒ}t|tjƒsft‚dS(N(udatetimeunowu isinstanceuAssertionErrorudateutoday(unowutoday((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyutest_isinstance_without_activejs utest_isinstance_without_activeu 2013-04-09cBs |EeZdZdd„ZdS(uTestUnitTestClassDecoratorcCs,|jtjdddƒtjjƒƒdS(NiÝii (u assertEqualudatetimeudateutoday(uself((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyu&test_class_decorator_works_on_unittesttsuATestUnitTestClassDecorator.test_class_decorator_works_on_unittestN(u__name__u __module__u __qualname__u&test_class_decorator_works_on_unittest(u __locals__((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyuTestUnitTestClassDecoratorrsuTestUnitTestClassDecorator(udatetimeuunittestu freezegunu freeze_timeutest_simple_apiutest_tz_offsetutest_tz_offset_with_todayutest_bad_time_argumentutest_date_objectutest_invalid_typeutest_datetime_objectutest_decoratoruobjectuTesterutest_nice_datetimeutest_context_managerutest_isinstance_with_activeutest_isinstance_without_activeuTestCaseuTestUnitTestClassDecorator(((u;/Users/spulec/Development/freezegun/tests/test_datetimes.pyus$          freezegun-0.3.5/tests/__pycache__/test_import_alias.cpython-27-PYTEST.pyc0000644000076500000240000000471012464563635026717 0ustar spulecstaff00000000000000ó S£TGc@s|ddlZddljjZddlmZddlmZ ddl m Z edƒd„ƒZ edƒd„ƒZ dS( iÿÿÿÿN(t freeze_time(tdatetime(ttimes 1980-01-01c Cs†tj}|ƒ}d}d}d}t|||ƒ}||k}|sdtjd|fd||fƒitj|ƒd6dtjƒksštjtƒr©tjtƒndd6tj|ƒd6tj|ƒd 6dtjƒksñtjtƒrtjtƒndd 6tj|ƒd 6tj|ƒd 6tj|ƒd 6}di|d6}ttj |ƒƒ‚nd}}}}}}}dS(Ni¼is==sv%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.now }() } == %(py14)s {%(py14)s = %(py6)s(%(py8)s, %(py10)s, %(py12)s) }tpy8tdatetime_aliasedtpy0tpy2tpy4tpy6tpy12tpy14tpy10tsassert %(py16)stpy16(s==(sv%(py4)s {%(py4)s = %(py2)s {%(py2)s = %(py0)s.now }() } == %(py14)s {%(py14)s = %(py6)s(%(py8)s, %(py10)s, %(py12)s) }sassert %(py16)s( Rtnowt @pytest_art_call_reprcomparet _safereprt @py_builtinstlocalst_should_repr_global_nametAssertionErrort_format_explanationtNone( t @py_assert1t @py_assert3t @py_assert7t @py_assert9t @py_assert11t @py_assert13t @py_assert5t @py_format15t @py_format17((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyttest_datetime_aliass  ós 1970-01-01cCsØtƒ}d}||k}|sÆtjd |fd ||fƒidtjƒksctjtƒrrtjtƒndd6tj|ƒd6tj|ƒd6}d i|d 6}ttj|ƒƒ‚nd}}}dS(Ngs==s)%(py2)s {%(py2)s = %(py0)s() } == %(py5)st time_aliasedRRtpy5R sassert %(py7)stpy7(s==(s)%(py2)s {%(py2)s = %(py0)s() } == %(py5)ssassert %(py7)s( R"RRRRRRRRR(Rt @py_assert4Rt @py_format6t @py_format8((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyttest_time_alias s  |(t __builtin__Rt_pytest.assertion.rewritet assertiontrewriteRt freezegunRRRRR"R!R((((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyts freezegun-0.3.5/tests/__pycache__/test_operations.cpython-27-PYTEST.pyc0000644000076500000240000002040412464563635026415 0ustar spulecstaff00000000000000ó ï‘Th c@s#ddlZddljjZddlZddlmZddl m Z ddlm Z m Z ddl mZedƒd„ƒZedƒd„ƒZedƒd „ƒZd e fd „ƒYZed ƒd „ƒZed ddƒd„ƒZedƒd„ƒZedƒd„ƒZdS(iÿÿÿÿN(t freeze_time(t relativedelta(t timedeltattzinfo(tutilss 2012-01-14c CsØtjjƒ}|tjddƒ}|tddƒ}tj}||ƒ}|sddidtjƒks~tj tƒrtj tƒndd6tj |ƒd6dtjƒksÅtj |ƒrÔtj |ƒndd 6tj |ƒd 6}t tj |ƒƒ‚nd}}tj}||ƒ}|sàddidtjƒksWtj tƒrftj tƒndd6tj |ƒd6d tjƒksžtj |ƒr­tj |ƒnd d 6tj |ƒd 6}t tj |ƒƒ‚nd}}tjjƒ}|tjddƒ}|tddƒ}tj}||ƒ}|sñdd idtjƒkshtj tƒrwtj tƒndd6tj |ƒd6d tjƒks¯tj |ƒr¾tj |ƒnd d 6tj |ƒd 6}t tj |ƒƒ‚nd}}tj}||ƒ}|sÊdd idtjƒksAtj tƒrPtj tƒndd6tj |ƒd6dtjƒksˆtj |ƒr—tj |ƒndd 6tj |ƒd 6}t tj |ƒƒ‚nd}}dS(NtdaysitsRassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_datetime }(%(py3)s) }Rtpy0tpy2tlatertpy3tpy5t other_latersNassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_date }(%(py3)s) }ttomorrowtother_tomorrow(tdatetimetnowRRRtis_fake_datetimet @py_builtinstlocalst @pytest_art_should_repr_global_namet _safereprtAssertionErrort_format_explanationtNonetdatettodayt is_fake_date( RR R t @py_assert1t @py_assert4t @py_format6RR R((s</Users/spulec/Development/freezegun/tests/test_operations.pyt test_additions< œ  œ  œ  œc Cstjjƒ}|tjddƒ}|tddƒ}||}tj}||ƒ}|sddidtjƒksˆtj tƒr—tj tƒndd6tj |ƒd6dtjƒksÏtj |ƒrÞtj |ƒndd 6tj |ƒd 6}t tj |ƒƒ‚nd}}tj}||ƒ}|sêddidtjƒksatj tƒrptj tƒndd6tj |ƒd6d tjƒks¨tj |ƒr·tj |ƒnd d 6tj |ƒd 6}t tj |ƒƒ‚nd}}tj}t||ƒ}|sýdd id tjƒks=tj tƒrLtj tƒnd d6dtjƒksttj |ƒrƒtj |ƒndd6dtjƒks«tj tƒrºtj tƒndd6tj |ƒd6tj |ƒd6} t tj | ƒƒ‚nd}}tjjƒ} | tjddƒ} | tddƒ} | | }tj}|| ƒ}|sddidtjƒkstj tƒržtj tƒndd6tj |ƒd6dtjƒksÖtj | ƒråtj | ƒndd 6tj |ƒd 6}t tj |ƒƒ‚nd}}tj}|| ƒ}|sñddidtjƒkshtj tƒrwtj tƒndd6tj |ƒd6dtjƒks¯tj | ƒr¾tj | ƒndd 6tj |ƒd 6}t tj |ƒƒ‚nd}}tj}t||ƒ}|sdd id tjƒksDtj tƒrStj tƒnd d6dtjƒks{tj |ƒrŠtj |ƒndd6dtjƒks²tj tƒrÁtj tƒndd6tj |ƒd6tj |ƒd6} t tj | ƒƒ‚nd}}dS(NRiRsRassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_datetime }(%(py3)s) }RRRtbeforeR R t other_beforesTassert %(py6)s {%(py6)s = %(py0)s(%(py1)s, %(py4)s {%(py4)s = %(py2)s.timedelta }) }t isinstancethow_longtpy1Rtpy4tpy6sNassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_date }(%(py3)s) }t yesterdaytother_yesterday(RRRRRRRRRRRRRRR#RRR( RR!R"R$RRRt @py_assert3t @py_assert5t @py_format7RR(R)((s</Users/spulec/Development/freezegun/tests/test_operations.pyttest_subtractionsX  œ  œ  Ó   œ  œ  ÓcCs8tjjddƒ}|jjtjdddƒƒdS(NttziÜii(RRRtshouldtequal(R((s</Users/spulec/Development/freezegun/tests/test_operations.pyttest_datetime_timezone_none*stGMT5cBs#eZd„Zd„Zd„ZRS(cCs tddƒS(Nthoursi(R(tselftdt((s</Users/spulec/Development/freezegun/tests/test_operations.pyt utcoffset1scCsdS(NsGMT +5((R4R5((s</Users/spulec/Development/freezegun/tests/test_operations.pyttzname3scCs tdƒS(Ni(R(R4R5((s</Users/spulec/Development/freezegun/tests/test_operations.pytdst5s(t__name__t __module__R6R7R8(((s</Users/spulec/Development/freezegun/tests/test_operations.pyR20s  s2012-01-14 2:00:00cCsftjjdtƒƒ}|jjtjdddddtƒƒƒ|jƒjjtdd ƒƒdS( NR.iÜiiiRii<iiiPF(RRR2R/R0R6R(R((s</Users/spulec/Development/freezegun/tests/test_operations.pyttest_datetime_timezone_real9s+t tz_offsetiüÿÿÿcCsftjjdtƒƒ}|jjtjdddddtƒƒƒ|jƒjjtdd ƒƒdS( NR.iÜiiiRii<iiiPF(RRR2R/R0R6R(R((s</Users/spulec/Development/freezegun/tests/test_operations.pyt'test_datetime_timezone_real_with_offset@s+s2012-01-14 00:00:00cCstjjdtƒƒ}|jtƒƒ}tj}||ƒ}|sùddidtjƒksptj tƒrtj tƒndd6tj |ƒd6dtjƒks·tj |ƒrÆtj |ƒndd6tj |ƒd 6}t tj |ƒƒ‚nd}}dS( NR.RsRassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_datetime }(%(py3)s) }RRRt convertedR R (RRR2t astimezoneRRRRRRRRRR(RR>RRR((s</Users/spulec/Development/freezegun/tests/test_operations.pyttest_astimezoneGs œcCsøtjjƒ}|jddƒ}tj}||ƒ}|sðddidtjƒksgtjtƒrvtj tƒndd6tj |ƒd6dtjƒks®tj|ƒr½tj |ƒndd 6tj |ƒd 6}t tj |ƒƒ‚nd}}tj jƒ}|jddƒ}tj}||ƒ}|sêdd idtjƒksatjtƒrptj tƒndd6tj |ƒd6d tjƒks¨tj|ƒr·tj |ƒnd d 6tj |ƒd 6}t tj |ƒƒ‚nd}}dS( NtyeariÝRsRassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_datetime }(%(py3)s) }RRRt modified_timeR R sNassert %(py5)s {%(py5)s = %(py2)s {%(py2)s = %(py0)s.is_fake_date }(%(py3)s) }t modified_date(RRtreplaceRRRRRRRRRRRRR(RRBRRRRRC((s</Users/spulec/Development/freezegun/tests/test_operations.pyt test_replaceNs  œ  œ(t __builtin__Rt_pytest.assertion.rewritet assertiontrewriteRRt freezegunRtdateutil.relativedeltaRRRttestsRR R-R1R2R;R=R@RE(((s</Users/spulec/Development/freezegun/tests/test_operations.pyts   freezegun-0.3.5/tests/__pycache__/test_operations.cpython-33.pyc0000644000076500000240000001024112161103373025341 0ustar spulecstaff00000000000000ž zß`Q£c@sæddlZddlZddlmZddlmZddlmZmZedƒdd„ƒZedƒdd „ƒZ edƒd d „ƒZ Gd d „d eƒZ edƒdd„ƒZ edddƒdd„ƒZ dS(iN(u freeze_time(u relativedelta(u timedeltautzinfou 2012-01-14cCsÔtjjƒ}|tjddƒ}|tddƒ}t|tjƒsPt‚t|tjƒsht‚tjjƒ}|tjddƒ}|tddƒ}t|tjƒs¸t‚t|tjƒsÐt‚dS(Nudaysi(udatetimeunowu timedeltau relativedeltau isinstanceuAssertionErrorudateutoday(unowulateru other_laterutodayutomorrowuother_tomorrow((u</Users/spulec/Development/freezegun/tests/test_operations.pyu test_additionsu test_additioncCstjjƒ}|tjddƒ}|tddƒ}||}t|tjƒsZt‚t|tjƒsrt‚t|tjƒsŠt‚tjjƒ}|tjddƒ}|tddƒ}||}t|tjƒsät‚t|tjƒsüt‚t|tjƒst‚dS(Nudaysi(udatetimeunowu timedeltau relativedeltau isinstanceuAssertionErrorudateutoday(unowubeforeu other_beforeuhow_longutodayu yesterdayuother_yesterday((u</Users/spulec/Development/freezegun/tests/test_operations.pyutest_subtractions  utest_subtractioncCs8tjjddƒ}|jjtjdddƒƒdS(NutziÜii(udatetimeunowuNoneushoulduequal(unow((u</Users/spulec/Development/freezegun/tests/test_operations.pyutest_datetime_timezone_none*sutest_datetime_timezone_nonecBs8|EeZdZdd„Zdd„Zdd„ZdS(uGMT5cCs tddƒS(Nuhoursi(u timedelta(uselfudt((u</Users/spulec/Development/freezegun/tests/test_operations.pyu utcoffset1suGMT5.utcoffsetcCsdS(NuGMT +5((uselfudt((u</Users/spulec/Development/freezegun/tests/test_operations.pyutzname3su GMT5.tznamecCs tdƒS(Ni(u timedelta(uselfudt((u</Users/spulec/Development/freezegun/tests/test_operations.pyudst5suGMT5.dstN(u__name__u __module__u __qualname__u utcoffsetutznameudst(u __locals__((u</Users/spulec/Development/freezegun/tests/test_operations.pyuGMT50s  uGMT5u2012-01-14 2:00:00cCsftjjdtƒƒ}|jjtjdddddtƒƒƒ|jƒjjtdd ƒƒdS( NutziÜiiiutzinfoii<iiiPF(udatetimeunowuGMT5ushoulduequalu utcoffsetu timedelta(unow((u</Users/spulec/Development/freezegun/tests/test_operations.pyutest_datetime_timezone_real9s+utest_datetime_timezone_realu tz_offseticCsftjjdtƒƒ}|jjtjdddddtƒƒƒ|jƒjjtdd ƒƒdS( NutziÜiiiutzinfoii<iiiPF(udatetimeunowuGMT5ushoulduequalu utcoffsetu timedelta(unow((u</Users/spulec/Development/freezegun/tests/test_operations.pyu'test_datetime_timezone_real_with_offset@s+u'test_datetime_timezone_real_with_offsetiüÿÿÿ(udatetimeusureu freezegunu freeze_timeudateutil.relativedeltau relativedeltau timedeltautzinfou test_additionutest_subtractionutest_datetime_timezone_noneuGMT5utest_datetime_timezone_realu'test_datetime_timezone_real_with_offset(((u</Users/spulec/Development/freezegun/tests/test_operations.pyus   freezegun-0.3.5/tests/__pycache__/test_pickle.cpython-27-PYTEST.pyc0000644000076500000240000001371712464563635025512 0ustar spulecstaff00000000000000ó †;Tþc@szddlZddljjZddlZddlZddlm Z ddl Z d„Z d„Z d„Z d„ZdS(iÿÿÿÿN(t freeze_timecCsÒ tjj}tjj}tjj}tjj}tjjƒ}tjjƒ}tjjƒ}tj}tj }||ƒ} || ƒ} | |k} | rt j df| fdf| |fƒit j | ƒd6dt jƒkpït jtƒrt j tƒndd6t j |ƒd6dt jƒkp6t jtƒrHt j tƒndd6t j |ƒd6d t jƒkp}t j|ƒrt j |ƒnd d 6d t jƒkp´t j|ƒrÆt j |ƒnd d 6t j | ƒd 6} d di| d6} tt j| ƒƒ‚nt}}} } } tj}tj }||ƒ} || ƒ} | |k} | rÕt j df| fdf| |fƒit j | ƒd6dt jƒkp¶t jtƒrÈt j tƒndd6t j |ƒd6dt jƒkpýt jtƒrt j tƒndd6t j |ƒd6dt jƒkpDt j|ƒrVt j |ƒndd 6dt jƒkp{t j|ƒrt j |ƒndd 6t j | ƒd 6} d di| d6} tt j| ƒƒ‚nt}}} } } tj}tj }||ƒ} || ƒ} | |k} | rœt j df| fdf| |fƒit j | ƒd6dt jƒkp}t jtƒrt j tƒndd6t j |ƒd6dt jƒkpÄt jtƒrÖt j tƒndd6t j |ƒd6dt jƒkp t j|ƒrt j |ƒndd 6dt jƒkpBt j|ƒrTt j |ƒndd 6t j | ƒd 6} d di| d6} tt j| ƒƒ‚nt}}} } } tj}tj }||ƒ} || ƒ} | |k} | rct j df| fdf| |fƒit j | ƒd6dt jƒkpDt jtƒrVt j tƒndd6t j |ƒd6dt jƒkp‹t jtƒrt j tƒndd6t j |ƒd6dt jƒkpÒt j|ƒrät j |ƒndd 6dt jƒkp t j|ƒrt j |ƒndd 6t j | ƒd 6} d di| d6} tt j| ƒƒ‚nt}}} } } tj}tj }||ƒ} || ƒ} | |k} | r* t j df| fdf| |fƒit j | ƒd6dt jƒkp t jtƒrt j tƒndd6t j |ƒd6dt jƒkpRt jtƒrdt j tƒndd6t j |ƒd6dt jƒkp™t j|ƒr«t j |ƒndd 6dt jƒkpÐt j|ƒrât j |ƒndd 6t j | ƒd 6} d di| d6} tt j| ƒƒ‚nt}}} } } tj}tj }||ƒ} || ƒ} | |k} | rñ t j df| fdf| |fƒit j | ƒd6dt jƒkpÒ t jtƒrä t j tƒndd6t j |ƒd6dt jƒkp t jtƒr+ t j tƒndd6t j |ƒd6dt jƒkp` t j|ƒrr t j |ƒndd 6dt jƒkp— t j|ƒr© t j |ƒndd 6t j | ƒd 6} d di| d6} tt j| ƒƒ‚nt}}} } } tj}tj }||ƒ} || ƒ} | |k} | r¸ t j df| fdf| |fƒit j | ƒd6dt jƒkp™ t jtƒr« t j tƒndd6t j |ƒd6dt jƒkpà t jtƒrò t j tƒndd6t j |ƒd6dt jƒkp' t j|ƒr9 t j |ƒndd 6dt jƒkp^ t j|ƒrp t j |ƒndd 6t j | ƒd 6} d di| d6} tt j| ƒƒ‚nt}}} } } dS(Ns==s‡%(py10)s {%(py10)s = %(py2)s {%(py2)s = %(py0)s.loads }(%(py8)s {%(py8)s = %(py5)s {%(py5)s = %(py3)s.dumps }(%(py6)s) }) } == %(py12)stpy8tpickletpy0tpy2tpy3tpy5t min_datetimetpy6tpy12tpy10tsassert %(py14)stpy14t max_datetimetmin_datetmax_datetnowttodaytutc_now(tdatetimetmintmaxtdateRRtutcnowRtloadstdumpst @pytest_art_call_reprcomparet _safereprt @py_builtinstlocalst_should_repr_global_nametAssertionErrort_format_explanationtNone(RR RRRRRt @py_assert1t @py_assert4t @py_assert7t @py_assert9t @py_assert11t @py_format13t @py_format15((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyt'assert_pickled_datetimes_equal_originals¨     ÿH ÿH ÿH ÿH ÿH ÿH ÿHcCs2tdƒ}|jƒtƒ|jƒtƒdS(Ns 2012-01-14(RtstartR*tstop(tfreezer((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyt test_pickles    cCsætjdddƒ}tjtj|ƒƒjj|ƒtdƒ}|jƒtjjƒ}tjtj|ƒƒjj|ƒtjtj|ƒƒ|j ƒtjtj|ƒƒjj|ƒtjtj|ƒƒjj|ƒdS(Ni²iis 1970-01-01( RRRRtshouldtequalRR+RR,(t real_datetimeR-t fake_datetime((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyttest_pickle_real_datetime"s"  " "cCsætjdddƒ}tjtj|ƒƒjj|ƒtdƒ}|jƒtjj ƒ}tjtj|ƒƒjj|ƒtjtj|ƒƒ|j ƒtjtj|ƒƒjj|ƒtjtj|ƒƒjj|ƒdS(Ni²iis 1970-01-01( RRRRRR/R0RR+RR,(t real_dateR-t fake_date((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyttest_pickle_real_date1s"  " "(t __builtin__Rt_pytest.assertion.rewritet assertiontrewriteRRRt freezegunRtsureR*R.R3R6(((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyts      freezegun-0.3.5/tests/__pycache__/test_sqlite3.cpython-27-PYTEST.pyc0000644000076500000240000000176412464563635025626 0ustar spulecstaff00000000000000ó ïMSwc@stddlZddljjZddlZddlmZddl Z edƒd„ƒZ edƒd„ƒZ dS(iÿÿÿÿN(t freeze_times 2013-01-01cCs/tjdƒ}|jdtjjƒfƒdS(Ns/tmp/foosselect ?(tsqlite3tconnecttexecutetdatetimetnow(tdb((s9/Users/spulec/Development/freezegun/tests/test_sqlite3.pyttest_fake_datetime_selectscCs/tjdƒ}|jdtjjƒfƒdS(Ns/tmp/foosselect ?(RRRRtdatettoday(R((s9/Users/spulec/Development/freezegun/tests/test_sqlite3.pyttest_fake_date_select s( t __builtin__t @py_builtinst_pytest.assertion.rewritet assertiontrewritet @pytest_arRt freezegunRRRR (((s9/Users/spulec/Development/freezegun/tests/test_sqlite3.pyts   freezegun-0.3.5/tests/fake_module.py0000644000076500000240000000122312557140450020117 0ustar spulecstaff00000000000000from datetime import datetime from datetime import date from time import time, localtime, gmtime, strftime def fake_datetime_function(): return datetime.now() def fake_date_function(): return date.today() def fake_time_function(): return time() def fake_localtime_function(): return localtime() def fake_gmtime_function(): return gmtime() def fake_strftime_function(): return strftime("%Y") class EqualToAnything(object): description = 'This is the equal_to_anything object' def __eq__(self, other): return True def __neq__(self, other): return False equal_to_anything = EqualToAnything() freezegun-0.3.5/tests/fake_module.pyc0000644000076500000240000000403212505565144020267 0ustar spulecstaff00000000000000ó =ªÖTc@s›ddlmZddlmZddlmZmZmZmZd„Zd„Zd„Zd„Z d„Z d „Z d e fd „ƒYZ e ƒZd S( iÿÿÿÿ(tdatetime(tdate(ttimet localtimetgmtimetstrftimecCs tjƒS(N(Rtnow(((s8/Users/spulec/Development/freezegun/tests/fake_module.pytfake_datetime_functionscCs tjƒS(N(Rttoday(((s8/Users/spulec/Development/freezegun/tests/fake_module.pytfake_date_function scCstƒS(N(R(((s8/Users/spulec/Development/freezegun/tests/fake_module.pytfake_time_functionscCstƒS(N(R(((s8/Users/spulec/Development/freezegun/tests/fake_module.pytfake_localtime_functionscCstƒS(N(R(((s8/Users/spulec/Development/freezegun/tests/fake_module.pytfake_gmtime_functionscCs tdƒS(Ns%Y(R(((s8/Users/spulec/Development/freezegun/tests/fake_module.pytfake_strftime_functionstEqualToAnythingcBs eZdZd„Zd„ZRS(s$This is the equal_to_anything objectcCstS(N(tTrue(tselftother((s8/Users/spulec/Development/freezegun/tests/fake_module.pyt__eq__!scCstS(N(tFalse(RR((s8/Users/spulec/Development/freezegun/tests/fake_module.pyt__neq__$s(t__name__t __module__t descriptionRR(((s8/Users/spulec/Development/freezegun/tests/fake_module.pyRs N(RRRRRRRR R R R R tobjectRtequal_to_anything(((s8/Users/spulec/Development/freezegun/tests/fake_module.pyts"       freezegun-0.3.5/tests/single_import_module.pyc0000644000076500000240000000056712557140033022236 0ustar spulecstaff00000000000000ó À¼Uc@sddlmZd„ZdS(iÿÿÿÿ(tdatetimecCs tjƒS(N(Rtnow(((sA/Users/spulec/Development/freezegun/tests/single_import_module.pytfoobarsN(RR(((sA/Users/spulec/Development/freezegun/tests/single_import_module.pytsfreezegun-0.3.5/tests/test_class_import.py0000644000076500000240000000457712557140450021421 0ustar spulecstaff00000000000000import time from .fake_module import ( equal_to_anything, fake_date_function, fake_datetime_function, fake_gmtime_function, fake_localtime_function, fake_strftime_function, fake_time_function, ) from . import fake_module from freezegun import freeze_time from freezegun.api import FakeDatetime import datetime @freeze_time("2012-01-14") def test_import_datetime_works(): assert fake_datetime_function().day == 14 @freeze_time("2012-01-14") def test_import_date_works(): assert fake_date_function().day == 14 @freeze_time("2012-01-14") def test_import_time(): local_time = datetime.datetime(2012, 1, 14) utc_time = local_time - datetime.timedelta(seconds=time.timezone) expected_timestamp = time.mktime(utc_time.timetuple()) assert fake_time_function() == expected_timestamp def test_start_and_stop_works(): freezer = freeze_time("2012-01-14") result = fake_datetime_function() assert result.__class__ == datetime.datetime assert result.__class__ != FakeDatetime freezer.start() assert fake_datetime_function().day == 14 assert isinstance(fake_datetime_function(), datetime.datetime) assert isinstance(fake_datetime_function(), FakeDatetime) freezer.stop() result = fake_datetime_function() assert result.__class__ == datetime.datetime assert result.__class__ != FakeDatetime def test_isinstance_works(): date = datetime.date.today() now = datetime.datetime.now() freezer = freeze_time('2011-01-01') freezer.start() assert isinstance(date, datetime.date) assert not isinstance(date, datetime.datetime) assert isinstance(now, datetime.datetime) assert isinstance(now, datetime.date) freezer.stop() @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' @freeze_time("2012-01-14 12:00:00") def test_import_localtime(): struct = fake_localtime_function() assert struct.tm_year == 2012 assert struct.tm_mon == 1 assert struct.tm_mday == 14 @freeze_time("2012-01-14 12:00:00") def test_fake_gmtime_function(): struct = fake_gmtime_function() assert struct.tm_year == 2012 assert struct.tm_mon == 1 assert struct.tm_mday == 14 @freeze_time("2012-01-14") def test_fake_strftime_function(): assert fake_strftime_function() == '2012' freezegun-0.3.5/tests/test_class_import.pyc0000644000076500000240000000723512505565144021562 0ustar spulecstaff00000000000000ó Y âTc@s%ddlZddlmZmZmZmZmZmZmZddl mZddl m Z ddl m Z ddlZe dƒd„ƒZe dƒd „ƒZe dƒd „ƒZd „Zd „Ze d ƒd„ƒZe dƒd„ƒZe dƒd„ƒZe dƒd„ƒZdS(iÿÿÿÿNi(tequal_to_anythingtfake_date_functiontfake_datetime_functiontfake_gmtime_functiontfake_localtime_functiontfake_strftime_functiontfake_time_function(t fake_module(t freeze_time(t FakeDatetimes 2012-01-14cCstƒjdkst‚dS(Ni(RtdaytAssertionError(((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_import_datetime_worksscCstƒjdkst‚dS(Ni(RR R (((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_import_date_worksscCs\tjdddƒ}|tjdtjƒ}tj|jƒƒ}tƒ|ksXt‚dS(NiÜiitseconds(tdatetimet timedeltattimettimezonetmktimet timetupleRR (t local_timetutc_timetexpected_timestamp((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_import_timescCsÛtdƒ}tƒ}|jtjks-t‚|jtksBt‚|jƒtƒjdksdt‚ttƒtjƒst‚ttƒtƒs—t‚|j ƒtƒ}|jtjksÂt‚|jtks×t‚dS(Ns 2012-01-14i( RRt __class__RR R tstartR t isinstancetstop(tfreezertresult((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_start_and_stop_works#s     cCs£tjjƒ}tjjƒ}tdƒ}|jƒt|tjƒsLt‚t|tjƒ set‚t|tjƒs}t‚t|tjƒs•t‚|jƒdS(Ns 2011-01-01( RtdatettodaytnowRRRR R(R R"R((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_isinstance_works5s  s 2011-01-01cCstjjdkst‚dS(Ns$This is the equal_to_anything object(RRt descriptionR (((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyt&test_avoid_replacing_equal_to_anythingBss2012-01-14 12:00:00cCsLtƒ}|jdkst‚|jdks3t‚|jdksHt‚dS(NiÜii(Rttm_yearR ttm_monttm_mday(tstruct((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_import_localtimeGs cCsLtƒ}|jdkst‚|jdks3t‚|jdksHt‚dS(NiÜii(RR&R R'R((R)((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_fake_gmtime_functionOs cCstƒdkst‚dS(Nt2012(RR (((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyttest_fake_strftime_functionWs(RRRRRRRRRtt freezegunRt freezegun.apiR RR R RRR#R%R*R+R-(((s>/Users/spulec/Development/freezegun/tests/test_class_import.pyts 4    freezegun-0.3.5/tests/test_datetimes.py0000644000076500000240000003710012557140450020665 0ustar spulecstaff00000000000000import time import datetime import unittest import locale import sys from nose.plugins import skip from tests import utils from freezegun import freeze_time from freezegun.api import FakeDatetime, FakeDate class temp_locale(object): """Temporarily change the locale.""" def __init__(self, *targets): self.targets = targets def __enter__(self): self.old = locale.setlocale(locale.LC_ALL) for target in self.targets: try: locale.setlocale(locale.LC_ALL, target) return except locale.Error: pass msg = 'could not set locale to any of: %s' % ', '.join(self.targets) raise skip.SkipTest(msg) def __exit__(self, *args): locale.setlocale(locale.LC_ALL, self.old) # Small sample of locales where '%x' expands to a dd/mm/yyyy string, # which can cause trouble when parsed with dateutil. _dd_mm_yyyy_locales = ['da_DK.UTF-8', 'de_DE.UTF-8', 'fr_FR.UTF-8'] def test_simple_api(): # time to freeze is always provided in UTC freezer = freeze_time("2012-01-14") # expected timestamp must be a timestamp, corresponding to 2012-01-14 UTC local_time = datetime.datetime(2012, 1, 14) utc_time = local_time - datetime.timedelta(seconds=time.timezone) expected_timestamp = time.mktime(utc_time.timetuple()) freezer.start() assert time.time() == expected_timestamp assert 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 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") freezer.start() assert datetime.datetime.now() == datetime.datetime(2012, 1, 10, 13, 52, 1) freezer.stop() def test_tz_offset(): freezer = freeze_time("2012-01-14 03:21:34", tz_offset=-4) # expected timestamp must be a timestamp, # corresponding to 2012-01-14 03:21:34 UTC # and it doesn't depend on tz_offset local_time = datetime.datetime(2012, 1, 14, 3, 21, 34) utc_time = local_time - datetime.timedelta(seconds=time.timezone) expected_timestamp = time.mktime(utc_time.timetuple()) freezer.start() assert datetime.datetime.now() == datetime.datetime(2012, 1, 13, 23, 21, 34) assert datetime.datetime.utcnow() == datetime.datetime(2012, 1, 14, 3, 21, 34) assert time.time() == expected_timestamp freezer.stop() def test_tz_offset_with_today(): freezer = freeze_time("2012-01-14", tz_offset=-4) freezer.start() assert datetime.date.today() == datetime.date(2012, 1, 13) freezer.stop() assert datetime.date.today() != datetime.date(2012, 1, 13) def test_zero_tz_offset_with_time(): # we expect the system to behave like a system with UTC timezone # at the beginning of the Epoch freezer = freeze_time('1970-01-01') freezer.start() assert datetime.date.today() == datetime.date(1970, 1, 1) assert datetime.datetime.now() == datetime.datetime(1970, 1, 1) assert datetime.datetime.utcnow() == datetime.datetime(1970, 1, 1) assert time.time() == 0.0 freezer.stop() def test_tz_offset_with_time(): # we expect the system to behave like a system with UTC-4 timezone # at the beginning of the Epoch (wall clock should be 4 hrs late) freezer = freeze_time('1970-01-01', tz_offset=-4) freezer.start() assert datetime.date.today() == datetime.date(1969, 12, 31) assert datetime.datetime.now() == datetime.datetime(1969, 12, 31, 20) assert datetime.datetime.utcnow() == datetime.datetime(1970, 1, 1) assert time.time() == 0.0 freezer.stop() def test_time_with_microseconds(): freezer = freeze_time(datetime.datetime(1970, 1, 1, 0, 0, 1, 123456)) freezer.start() assert time.time() == 1.123456 freezer.stop() def test_time_with_dst(): freezer = freeze_time(datetime.datetime(1970, 6, 1, 0, 0, 1, 123456)) freezer.start() assert time.time() == 13046401.123456 freezer.stop() def test_bad_time_argument(): try: freeze_time("2012-13-14", tz_offset=-4) except ValueError: pass else: assert False, "Bad values should raise a ValueError" def test_time_gmtime(): with freeze_time('2012-01-14 03:21:34'): time_struct = time.gmtime() assert time_struct.tm_year == 2012 assert time_struct.tm_mon == 1 assert time_struct.tm_mday == 14 assert time_struct.tm_hour == 3 assert time_struct.tm_min == 21 assert time_struct.tm_sec == 34 assert time_struct.tm_wday == 5 assert time_struct.tm_yday == 14 assert time_struct.tm_isdst == -1 class modify_timezone(object): def __init__(self, new_timezone): self.new_timezone = new_timezone self.original_timezone = time.timezone def __enter__(self): time.timezone = self.new_timezone def __exit__(self, *args): time.timezone = self.original_timezone def test_time_localtime(): with modify_timezone(-3600): # Set this for UTC-1 with freeze_time('2012-01-14 03:21:34'): time_struct = time.localtime() assert time_struct.tm_year == 2012 assert time_struct.tm_mon == 1 assert time_struct.tm_mday == 14 assert time_struct.tm_hour == 4 # offset of 1 hour due to time zone assert time_struct.tm_min == 21 assert time_struct.tm_sec == 34 assert time_struct.tm_wday == 5 assert time_struct.tm_yday == 14 assert time_struct.tm_isdst == -1 def test_strftime(): with modify_timezone(0): with freeze_time('1970-01-01'): assert time.strftime("%Y") == "1970" def test_date_object(): frozen_date = datetime.date(year=2012, month=11, day=10) date_freezer = freeze_time(frozen_date) regular_freezer = freeze_time('2012-11-10') assert date_freezer.time_to_freeze == regular_freezer.time_to_freeze def test_old_date_object(): frozen_date = datetime.date(year=1, month=1, day=1) with freeze_time(frozen_date): assert datetime.date.today() == frozen_date def test_date_with_locale(): with temp_locale(*_dd_mm_yyyy_locales): frozen_date = datetime.date(year=2012, month=1, day=2) date_freezer = freeze_time(frozen_date) assert date_freezer.time_to_freeze.date() == frozen_date def test_invalid_type(): try: freeze_time(int(4)) except TypeError: pass else: assert False, "Bad types should raise a TypeError" def test_datetime_object(): frozen_datetime = datetime.datetime(year=2012, month=11, day=10, hour=4, minute=15, second=30) datetime_freezer = freeze_time(frozen_datetime) regular_freezer = freeze_time('2012-11-10 04:15:30') assert datetime_freezer.time_to_freeze == regular_freezer.time_to_freeze def test_old_datetime_object(): frozen_datetime = datetime.datetime(year=1, month=7, day=12, hour=15, minute=6, second=3) with freeze_time(frozen_datetime): assert datetime.datetime.now() == frozen_datetime def test_datetime_with_locale(): with temp_locale(*_dd_mm_yyyy_locales): frozen_datetime = datetime.datetime(year=2012, month=1, day=2) date_freezer = freeze_time(frozen_datetime) assert date_freezer.time_to_freeze == frozen_datetime @freeze_time("2012-01-14") def test_decorator(): assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) def test_decorator_wrapped_attribute(): def to_decorate(): pass wrapped = freeze_time("2014-01-14")(to_decorate) assert wrapped.__wrapped__ is to_decorate class Callable(object): def __call__(self, *args, **kws): return (args, kws) @freeze_time("2012-01-14") class Tester(object): def test_the_class(self): assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) def test_still_the_same(self): assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) def test_class_name_preserved_by_decorator(self): assert self.__class__.__name__ == "Tester" class NotATestClass(object): def perform_operation(self): return datetime.date.today() @freeze_time('2001-01-01') def test_class_decorator_ignores_nested_class(self): not_a_test = self.NotATestClass() assert not_a_test.perform_operation() == datetime.date(2001, 1, 1) a_mock = Callable() def test_class_decorator_skips_callable_object_py2(self): if sys.version_info[0] != 2: raise skip.SkipTest("test target is Python2") assert self.a_mock.__class__ == Callable def test_class_decorator_wraps_callable_object_py3(self): if sys.version_info[0] != 3: raise skip.SkipTest("test target is Python3") assert self.a_mock.__wrapped__.__class__ == Callable @staticmethod def helper(): return datetime.date.today() def test_class_decorator_respects_staticmethod(self): assert self.helper() == datetime.date(2012, 1, 14) @freeze_time("Jan 14th, 2012") def test_nice_datetime(): assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) @freeze_time("2012-01-14") def test_datetime_date_method(): now = datetime.datetime.now() assert now.date() == FakeDate(2012, 1, 14) def test_context_manager(): with freeze_time("2012-01-14"): assert datetime.datetime.now() == datetime.datetime(2012, 1, 14) assert datetime.datetime.now() != datetime.datetime(2012, 1, 14) def test_nested_context_manager(): with freeze_time("2012-01-14"): with freeze_time("2012-12-25"): _assert_datetime_date_and_time_are_all_equal(datetime.datetime(2012, 12, 25)) _assert_datetime_date_and_time_are_all_equal(datetime.datetime(2012, 1, 14)) assert datetime.datetime.now() > datetime.datetime(2013, 1, 1) def _assert_datetime_date_and_time_are_all_equal(expected_datetime): assert datetime.datetime.now() == expected_datetime assert datetime.date.today() == expected_datetime.date() datetime_from_time = datetime.datetime.fromtimestamp(time.time()) timezone_adjusted_datetime = datetime_from_time + datetime.timedelta(seconds=time.timezone) assert timezone_adjusted_datetime == expected_datetime def test_nested_context_manager_with_tz_offsets(): with freeze_time("2012-01-14 23:00:00", tz_offset=2): with freeze_time("2012-12-25 19:00:00", tz_offset=6): assert datetime.datetime.now() == datetime.datetime(2012, 12, 26, 1) assert datetime.date.today() == datetime.date(2012, 12, 26) #no assertion for time.time() since it's not affected by tz_offset assert datetime.datetime.now() == datetime.datetime(2012, 1, 15, 1) assert datetime.date.today() == datetime.date(2012, 1, 15) assert datetime.datetime.now() > datetime.datetime(2013, 1, 1) @freeze_time("Jan 14th, 2012") def test_isinstance_with_active(): now = datetime.datetime.now() assert utils.is_fake_datetime(now) assert utils.is_fake_date(now.date()) today = datetime.date.today() assert utils.is_fake_date(today) def test_isinstance_without_active(): now = datetime.datetime.now() assert isinstance(now, datetime.datetime) assert isinstance(now, datetime.date) assert isinstance(now.date(), datetime.date) today = datetime.date.today() assert isinstance(today, datetime.date) @freeze_time('2013-04-09') class TestUnitTestClassDecorator(unittest.TestCase): @classmethod def setUpClass(cls): assert datetime.date(2013, 4, 9) == datetime.date.today() def setUp(self): self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today()) def tearDown(self): self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today()) @classmethod def tearDownClass(cls): assert datetime.date(2013, 4, 9) == datetime.date.today() def test_class_decorator_works_on_unittest(self): self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today()) def test_class_name_preserved_by_decorator(self): self.assertEqual(self.__class__.__name__, "TestUnitTestClassDecorator") @freeze_time('2013-04-09') class TestUnitTestClassDecoratorWithNoSetUpOrTearDown(unittest.TestCase): def test_class_decorator_works_on_unittest(self): self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today()) class TestUnitTestClassDecoratorSubclass(TestUnitTestClassDecorator): @classmethod def setUpClass(cls): # the super() call can fail if the class decoration was done wrong super(TestUnitTestClassDecoratorSubclass, cls).setUpClass() @classmethod def tearDownClass(cls): # the super() call can fail if the class decoration was done wrong super(TestUnitTestClassDecoratorSubclass, cls).tearDownClass() def test_class_name_preserved_by_decorator(self): self.assertEqual(self.__class__.__name__, "TestUnitTestClassDecoratorSubclass") class BaseInheritanceFreezableTests(unittest.TestCase): @classmethod def setUpClass(cls): pass @classmethod def tearDownClass(cls): pass class UnfrozenInheritedTests(BaseInheritanceFreezableTests): def test_time_is_not_frozen(self): # In this class, time should not be frozen - and the below decorated # class shouldn't affect that self.assertNotEqual(datetime.date(2013, 4, 9), datetime.date.today()) @freeze_time('2013-04-09') class FrozenInheritedTests(BaseInheritanceFreezableTests): def test_time_is_frozen(self): # In this class, time should be frozen self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today()) def test_min_and_max(): freezer = freeze_time("2012-01-14") real_datetime = datetime.datetime real_date = datetime.date freezer.start() assert datetime.datetime.min.__class__ == FakeDatetime assert datetime.datetime.max.__class__ == FakeDatetime assert datetime.date.min.__class__ == FakeDate assert datetime.date.max.__class__ == FakeDate assert datetime.datetime.min.__class__ != real_datetime assert datetime.datetime.max.__class__ != real_datetime assert datetime.date.min.__class__ != real_date assert datetime.date.max.__class__ != real_date freezer.stop() assert datetime.datetime.min.__class__ == datetime.datetime assert datetime.datetime.max.__class__ == datetime.datetime assert datetime.date.min.__class__ == datetime.date assert datetime.date.max.__class__ == datetime.date assert datetime.datetime.min.__class__ != FakeDatetime assert datetime.datetime.max.__class__ != FakeDatetime assert datetime.date.min.__class__ != FakeDate assert datetime.date.max.__class__ != FakeDate @freeze_time("2014-07-30T01:00:00Z") def test_freeze_with_timezone_aware_datetime_in_utc(): """ utcnow() should always return a timezone naive datetime """ utc_now = datetime.datetime.utcnow() assert utc_now.tzinfo == None @freeze_time("1970-01-01T00:00:00-04:00") def test_freeze_with_timezone_aware_datetime_in_non_utc(): """ we expect the system to behave like a system with UTC-4 timezone at the beginning of the Epoch (wall clock should be 4 hrs late) """ utc_now = datetime.datetime.utcnow() assert utc_now.tzinfo == None assert utc_now == datetime.datetime(1970, 1, 1, 4) freezegun-0.3.5/tests/test_datetimes.pyc0000644000076500000240000005065612537142550021044 0ustar spulecstaff00000000000000ó gÅ|Uc@s«ddlZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z defd„ƒYZdd d gZd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zdefd„ƒYZd„Zd„Zd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#e dƒd „ƒZ$d!„Z%e dƒd"efd#„ƒYƒZ&e d$ƒd%„ƒZ'e dƒd&„ƒZ(d'„Z)d(„Z*d)„Z+d*„Z,e d$ƒd+„ƒZ-d,„Z.d-efd.„ƒYZ/e d/ƒd0ej0fd1„ƒYƒZ1e d/ƒd2ej0fd3„ƒYƒZ2d4„Z3d5„Z4e d6ƒd7„ƒZ5e d8ƒd9„ƒZ6dS(:iÿÿÿÿN(tskip(tutils(t freeze_time(t FakeDatetimetFakeDatet temp_localecBs)eZdZd„Zd„Zd„ZRS(sTemporarily change the locale.cGs ||_dS(N(ttargets(tselfR((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt__init__scCs„tjtjƒ|_xC|jD]8}ytjtj|ƒdSWqtjk rVqXqWddj|jƒ}tj|ƒ‚dS(Ns"could not set locale to any of: %ss, ( tlocalet setlocaletLC_ALLtoldRtErrortjoinRtSkipTest(Rttargettmsg((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt __enter__scGstjtj|jƒdS(N(R R R R (Rtargs((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt__exit__s(t__name__t __module__t__doc__RRR(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRs  s da_DK.UTF-8s de_DE.UTF-8s fr_FR.UTF-8cCsìtdƒ}tjdddƒ}|tjdtjƒ}tj|jƒƒ}|jƒtjƒ|ksqt‚tjj ƒtjdddƒks›t‚tjj ƒtjdddƒksÅt‚tj j ƒtj dddƒksït‚tjj ƒj ƒtjdddƒkst‚|j ƒtjƒ|ksAt‚tjj ƒtjdddƒkskt‚tjj ƒtjdddƒks•t‚tdƒ}|jƒtjj ƒtjddddd dƒksÞt‚|j ƒdS( Ns 2012-01-14iÜiitsecondss2012-01-10 13:52:01i i i4(Rtdatetimet timedeltattimettimezonetmktimet timetupletstarttAssertionErrortnowtutcnowtdatettodaytstop(tfreezert local_timetutc_timetexpected_timestamp((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_simple_api's$  ***0 **  3cCsôtdddƒ}tjdddddd ƒ}|tjd tjƒ}tj|jƒƒ}|jƒtjjƒtjddd d dd ƒks›t ‚tjj ƒtjdddddd ƒksÎt ‚tjƒ|ksæt ‚|j ƒdS( Ns2012-01-14 03:21:34t tz_offsetiüÿÿÿiÜiiiii"Ri i( RRRRRRRRR!R R"R%(R&R'R(R)((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_tz_offset?s 33cCs~tdddƒ}|jƒtjjƒtjdddƒksFt‚|jƒtjjƒtjdddƒkszt‚dS(Ns 2012-01-14R+iüÿÿÿiÜii (RRRR#R$R R%(R&((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_tz_offset_with_todayOs  * cCsºtdƒ}|jƒtjjƒtjdddƒks@t‚tjjƒtjdddƒksjt‚tjjƒtjdddƒks”t‚tjƒdks¬t‚|j ƒdS(Ns 1970-01-01i²ig( RRRR#R$R R!R"RR%(R&((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_zero_tz_offset_with_timeWs  ***cCsÃtdddƒ}|jƒtjjƒtjdddƒksFt‚tjjƒtjddddƒksst‚tjjƒtjdd d ƒkst‚tjƒd ksµt‚|j ƒdS( Ns 1970-01-01R+iüÿÿÿi±i iii²ig( RRRR#R$R R!R"RR%(R&((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_tz_offset_with_timecs *-*c CsWttjdddddddƒƒ}|jƒtjƒdksIt‚|jƒdS(Ni²iii@âglë§ÿ¬ùñ?(RRRRR R%(R&((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_time_with_microsecondsos' c CsWttjdddddddƒƒ}|jƒtjƒdksIt‚|jƒdS(Ni²iiii@âgÿYó#PâhA(RRRRR R%(R&((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_time_with_dstus' cCs>ytdddƒWntk r'nXts:tdƒ‚dS(Ns 2012-13-14R+iüÿÿÿs$Bad values should raise a ValueError(Rt ValueErrortFalseR (((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_bad_time_argument{s  cCsàtdƒÎtjƒ}|jdks.t‚|jdksCt‚|jdksXt‚|jdksmt‚|jdks‚t‚|j dks—t‚|j dks¬t‚|j dksÁt‚|j d ksÖt‚WdQXdS( Ns2012-01-14 03:21:34iÜiiiii"iiÿÿÿÿ( RRtgmtimettm_yearR ttm_monttm_mdayttm_hourttm_minttm_secttm_wdayttm_ydayttm_isdst(t time_struct((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_time_gmtime„s  tmodify_timezonecBs#eZd„Zd„Zd„ZRS(cCs||_tj|_dS(N(t new_timezoneRRtoriginal_timezone(RRB((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR”s cCs|jt_dS(N(RBRR(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR˜scGs|jt_dS(N(RCRR(RR((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR›s(RRRRR(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRA’s  c CsótdƒátdƒÎtjƒ}|jdks;t‚|jdksPt‚|jdkset‚|jdkszt‚|j dkst‚|j dks¤t‚|j d ks¹t‚|j dksÎt‚|j d ksãt‚WdQXWdQXdS( Niðñÿÿs2012-01-14 03:21:34iÜiiiii"iiÿÿÿÿ(RARRt localtimeR6R R7R8R9R:R;R<R=R>(R?((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_time_localtimeŸs   c CsEtdƒ3tdƒ tjdƒdks5t‚WdQXWdQXdS(Nis 1970-01-01s%Yt1970(RARRtstrftimeR (((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt test_strftime®s  cCsRtjddddddƒ}t|ƒ}tdƒ}|j|jksNt‚dS(NtyeariÜtmonthi tdayi s 2012-11-10(RR#Rttime_to_freezeR (t frozen_datet date_freezertregular_freezer((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_date_object´s  cCsPtjddddddƒ}t|ƒ tjjƒ|ksFt‚WdQXdS(NRIiRJRK(RR#RR$R (RM((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_old_date_objectºs c Cs\ttŒJtjddddddƒ}t|ƒ}|jjƒ|ksRt‚WdQXdS(NRIiÜRJiRKi(Rt_dd_mm_yyyy_localesRR#RRLR (RMRN((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_date_with_locale¿s  cCs>yttdƒƒWntk r'nXts:tdƒ‚dS(Nis"Bad types should raise a TypeError(Rtintt TypeErrorR3R (((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_invalid_typeÅs  c Csdtjddddddddd d d d ƒ}t|ƒ}td ƒ}|j|jks`t‚dS(NRIiÜRJi RKi thouritminuteitsecondis2012-11-10 04:15:30(RRRLR (tfrozen_datetimetdatetime_freezerRO((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_datetime_objectÎs   c Csbtjddddddddd d d d ƒ}t|ƒ tjjƒ|ksXt‚WdQXdS( NRIiRJiRKi RWiRXiRYi(RRR!R (RZ((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_old_datetime_objectÕs c CsVttŒDtjddddddƒ}t|ƒ}|j|ksLt‚WdQXdS(NRIiÜRJiRKi(RRRRRRLR (RZRN((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_datetime_with_localeÛs  s 2012-01-14cCs.tjjƒtjdddƒks*t‚dS(NiÜii(RR!R (((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_decoratoráscCs4d„}tdƒ|ƒ}|j|ks0t‚dS(NcSsdS(N((((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt to_decorateçss 2014-01-14(Rt __wrapped__R (R`twrapped((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt test_decorator_wrapped_attributeæs tTestercBseZd„Zd„ZRS(cCs.tjjƒtjdddƒks*t‚dS(NiÜii(RR!R (R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_the_classðscCs.tjjƒtjdddƒks*t‚dS(NiÜii(RR!R (R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_still_the_sameós(RRReRf(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRdîs sJan 14th, 2012cCs.tjjƒtjdddƒks*t‚dS(NiÜii(RR!R (((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_nice_datetime÷scCs7tjjƒ}|jƒtdddƒks3t‚dS(NiÜii(RR!R#RR (R!((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_datetime_date_methodüsc Csktdƒ/tjjƒtjdddƒks7t‚WdQXtjjƒtjdddƒksgt‚dS(Ns 2012-01-14iÜii(RRR!R (((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_context_managers 0c Cs†tdƒJtdƒttjdddƒƒWdQXttjdddƒƒWdQXtjjƒtjdddƒks‚t‚dS( Ns 2012-01-14s 2012-12-25iÜi iiiiÝ(Rt,_assert_datetime_date_and_time_are_all_equalRR!R (((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_nested_context_managers   cCsƒtjjƒ|kst‚tjjƒ|jƒks<t‚tjjtjƒƒ}|tjdtjƒ}||kst‚dS(NR( RR!R R#R$t fromtimestampRRR(texpected_datetimetdatetime_from_timettimezone_adjusted_datetime((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRjs !cCstdddƒÌtdddƒ\tjjƒtjdddd ƒksSt‚tjjƒtjdddƒks}t‚WdQXtjjƒtjdd d d ƒks°t‚tjjƒtjdd d ƒksÚt‚WdQXtjjƒtjd d d ƒks t‚dS( Ns2012-01-14 23:00:00R+is2012-12-25 19:00:00iiÜi iiiiÝ(RRR!R R#R$(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt+test_nested_context_manager_with_tz_offsetss-0-0cCsgtjjƒ}tj|ƒs$t‚tj|jƒƒs?t‚tjjƒ}tj|ƒsct‚dS(N(RR!Rtis_fake_datetimeR t is_fake_dateR#R$(R!R$((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_isinstance_with_active#s cCsˆtjjƒ}t|tjƒs't‚t|tjƒs?t‚t|jƒtjƒs]t‚tjjƒ}t|tjƒs„t‚dS(N(RR!t isinstanceR R#R$(R!R$((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_isinstance_without_active-s tCallablecBseZd„ZRS(cOs ||fS(N((RRtkws((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt__call__9s(RRRx(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRv7ss 2013-04-09tTestUnitTestClassDecoratorcBs‡eZeƒZdefd„ƒYZed„ƒZed„ƒZ d„Z d„Z d„Z d„Z d„Zed ƒd „ƒZRS( t NotATestClasscBseZd„ZRS(cCs tjjƒS(N(RR#R$(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pytperform_operationDs(RRR{(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRzBscCs tjjƒS(N(RR#R$(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pythelperGscCs.tjdddƒtjjƒks*t‚dS(NiÝii (RR#R$R (tcls((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt setUpClassKscCs,|jtjdddƒtjjƒƒdS(NiÝii (t assertEqualRR#R$(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pytsetUpOscCs,|jtjdddƒtjjƒƒdS(NiÝii (RRR#R$(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt&test_class_decorator_works_on_unittestRscCs)|j|jƒtjdddƒƒdS(NiÝii (RR|RR#(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt*test_class_decorator_respects_staticmethodUscCs?tjddkr%tjdƒ‚n|j|jjtƒdS(Niistest target is Python2(tsyst version_infoRRRta_mockt __class__Rv(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt.test_class_decorator_skips_callable_object_py2XscCsBtjddkr%tjdƒ‚n|j|jjjtƒdS(Niistest target is Python3( RƒR„RRRR…RaR†Rv(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt.test_class_decorator_wraps_callable_object_py3]ss 2001-01-01cCs5|jƒ}|j|jƒtjdddƒƒdS(NiÑi(RzRR{RR#(Rt not_a_test((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt)test_class_decorator_ignores_nested_classbs (RRRvR…tobjectRzt staticmethodR|t classmethodR~R€RR‚R‡RˆRRŠ(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRy=s      t#TestUnitTestClassDecoratorWithSetupcBseZd„Zd„ZRS(cCsdS(N((R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyR€jscCs,|jtjdddƒtjjƒƒdS(NiÝii (RRR#R$(R((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRms(RRR€R(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyRŽhs cCsÜtjjj|kst‚tjjj|ks6t‚tjjj|ksQt‚tjjj|kslt‚tjjj|ks‡t‚tjjj|ks¢t‚tjjj|ks½t‚tjjj|ksØt‚dS(N(RtminR†R tmaxR#(t right_classt wrong_class((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pytassert_class_of_datetimesqscCsòtdƒ}tj}tj}|jƒtjjjtksCt‚tjjjtks^t‚tjjjt ksyt‚tjjjt ks”t‚tjjj|ks¯t‚tjjj|ksÊt‚tjjj|ksåt‚tjjj|kst‚|j ƒtjjjtjks(t‚tjjjtjksFt‚tjjjtjksdt‚tjjjtjks‚t‚tjjjtkst‚tjjjtks¸t‚tjjjt ksÓt‚tjjjt ksît‚dS(Ns 2012-01-14( RRR#RRR†RR RRR%(R&t real_datetimet real_date((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyttest_min_and_max|s*     s2014-07-30T01:00:00ZcCs(tjjƒ}|jdks$t‚dS(sA utcnow() should always return a timezone naive datetime N(RR"ttzinfotNoneR (tutc_now((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt/test_freeze_with_timezone_aware_datetime_in_utc–ss1970-01-01T00:00:00-04:00cCsLtjjƒ}|jdks$t‚|tjddddƒksHt‚dS(sŽ we expect the system to behave like a system with UTC-4 timezone at the beginning of the Epoch (wall clock should be 4 hrs late) i²iiN(RR"R—R˜R (R™((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pyt3test_freeze_with_timezone_aware_datetime_in_non_utcŸs(7RRtunittestR Rƒt nose.pluginsRttestsRt freezegunRt freezegun.apiRRR‹RRRR*R,R-R.R/R0R1R4R@RARERHRPRQRSRVR\R]R^R_RcRdRgRhRiRkRjRpRsRuRvtTestCaseRyRŽR“R–RšR›(((s;/Users/spulec/Development/freezegun/tests/test_datetimes.pytsd                           *   freezegun-0.3.5/tests/test_import_alias.py0000644000076500000240000000124212560662142021370 0ustar spulecstaff00000000000000from freezegun import freeze_time from datetime import datetime as datetime_aliased from time import time as time_aliased @freeze_time("1980-01-01") def test_datetime_alias(): assert datetime_aliased.now() == datetime_aliased(1980,1,1) @freeze_time("1970-01-01") def test_time_alias(): assert time_aliased() == 0.0 @freeze_time('2013-04-09') class TestCallOtherFuncInTestClassDecoratorWithAlias(object): def test_calls_other_method(self): assert datetime_aliased(2013,4,9) == datetime_aliased.today() self.some_other_func() assert datetime_aliased(2013,4,9) == datetime_aliased.today() def some_other_func(self): pass freezegun-0.3.5/tests/test_import_alias.pyc0000644000076500000240000000370212557140033021532 0ustar spulecstaff00000000000000ó À¼Uc@s‰ddlmZddlmZddlmZedƒd„ƒZedƒd„ƒZedƒd efd „ƒYƒZ d „Z d S( iÿÿÿÿ(t freeze_time(tdatetime(ttimes 1980-01-01cCs(tjƒtdddƒks$t‚dS(Ni¼i(tdatetime_aliasedtnowtAssertionError(((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyttest_datetime_aliasss 1970-01-01cCstƒdkst‚dS(Ng(t time_aliasedR(((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyttest_time_alias ss 2013-04-09t.TestCallOtherFuncInTestClassDecoratorWithAliascBseZd„Zd„ZRS(cCsVtdddƒtjƒks$t‚|jƒtdddƒtjƒksRt‚dS(NiÝii (RttodayRtsome_other_func(tself((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyttest_calls_other_methods$ cCsdS(N((R ((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyR s(t__name__t __module__R R (((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyR s c Csitdƒ6ddlm}|ƒtdddƒks>t‚WdQX|ƒtdddƒkset‚dS(Ns 2013-01-01iÿÿÿÿ(tfoobariÝi(Rtsingle_import_moduleRRR(R((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyt"test_import_inside_context_managers 'N( t freezegunRRRRRRRtobjectR R(((s>/Users/spulec/Development/freezegun/tests/test_import_alias.pyts  freezegun-0.3.5/tests/test_operations.py0000644000076500000240000000512412557140450021072 0ustar spulecstaff00000000000000import datetime from freezegun import freeze_time from dateutil.relativedelta import relativedelta from datetime import timedelta, tzinfo from tests import utils @freeze_time("2012-01-14") def test_addition(): now = datetime.datetime.now() later = now + datetime.timedelta(days=1) other_later = now + relativedelta(days=1) assert utils.is_fake_datetime(later) assert utils.is_fake_datetime(other_later) today = datetime.date.today() tomorrow = today + datetime.timedelta(days=1) other_tomorrow = today + relativedelta(days=1) assert utils.is_fake_date(tomorrow) assert utils.is_fake_date(other_tomorrow) @freeze_time("2012-01-14") def test_subtraction(): now = datetime.datetime.now() before = now - datetime.timedelta(days=1) other_before = now - relativedelta(days=1) how_long = now - before assert utils.is_fake_datetime(before) assert utils.is_fake_datetime(other_before) assert isinstance(how_long, datetime.timedelta) today = datetime.date.today() yesterday = today - datetime.timedelta(days=1) other_yesterday = today - relativedelta(days=1) how_long = today - yesterday assert utils.is_fake_date(yesterday) assert utils.is_fake_date(other_yesterday) assert isinstance(how_long, datetime.timedelta) @freeze_time("2012-01-14") def test_datetime_timezone_none(): now = datetime.datetime.now(tz=None) assert now == datetime.datetime(2012, 1, 14) class GMT5(tzinfo): def utcoffset(self,dt): return timedelta(hours=5) def tzname(self,dt): return "GMT +5" def dst(self,dt): return timedelta(0) @freeze_time("2012-01-14 2:00:00") def test_datetime_timezone_real(): now = datetime.datetime.now(tz=GMT5()) assert now == datetime.datetime(2012, 1, 14, 7, tzinfo=GMT5()) assert now.utcoffset() == timedelta(0, 60 * 60 * 5) @freeze_time("2012-01-14 2:00:00", tz_offset=-4) def test_datetime_timezone_real_with_offset(): now = datetime.datetime.now(tz=GMT5()) assert now == datetime.datetime(2012, 1, 14, 3, tzinfo=GMT5()) assert now.utcoffset() == timedelta(0, 60 * 60 * 5) @freeze_time("2012-01-14 00:00:00") def test_astimezone(): now = datetime.datetime.now(tz=GMT5()) converted = now.astimezone(GMT5()) assert utils.is_fake_datetime(converted) @freeze_time("2012-01-14 00:00:00") def test_replace(): now = datetime.datetime.now() modified_time = now.replace(year=2013) assert utils.is_fake_datetime(modified_time) today = datetime.date.today() modified_date = today.replace(year=2013) assert utils.is_fake_date(modified_date) freezegun-0.3.5/tests/test_operations.pyc0000644000076500000240000001023712505565146021244 0ustar spulecstaff00000000000000ó Y âTc@sddlZddlmZddlmZddlmZmZddlmZedƒd„ƒZ edƒd„ƒZ edƒd „ƒZ d efd „ƒYZ ed ƒd „ƒZ ed ddƒd„ƒZedƒd„ƒZedƒd„ƒZdS(iÿÿÿÿN(t freeze_time(t relativedelta(t timedeltattzinfo(tutilss 2012-01-14cCsÈtjjƒ}|tjddƒ}|tddƒ}tj|ƒsMt‚tj|ƒsbt‚tjjƒ}|tjddƒ}|tddƒ}tj |ƒs¯t‚tj |ƒsÄt‚dS(Ntdaysi( tdatetimetnowRRRtis_fake_datetimetAssertionErrortdatettodayt is_fake_date(Rtlatert other_laterR ttomorrowtother_tomorrow((s</Users/spulec/Development/freezegun/tests/test_operations.pyt test_additionscCs tjjƒ}|tjddƒ}|tddƒ}||}tj|ƒsWt‚tj|ƒslt‚t|tjƒs„t‚tjj ƒ}|tjddƒ}|tddƒ}||}tj |ƒsÛt‚tj |ƒsðt‚t|tjƒst‚dS(NRi( RRRRRRR t isinstanceR R R (Rtbeforet other_beforethow_longR t yesterdaytother_yesterday((s</Users/spulec/Development/freezegun/tests/test_operations.pyttest_subtractions  cCs:tjjddƒ}|tjdddƒks6t‚dS(NttziÜii(RRtNoneR (R((s</Users/spulec/Development/freezegun/tests/test_operations.pyttest_datetime_timezone_none*stGMT5cBs#eZd„Zd„Zd„ZRS(cCs tddƒS(Nthoursi(R(tselftdt((s</Users/spulec/Development/freezegun/tests/test_operations.pyt utcoffset1scCsdS(NsGMT +5((RR((s</Users/spulec/Development/freezegun/tests/test_operations.pyttzname3scCs tdƒS(Ni(R(RR((s</Users/spulec/Development/freezegun/tests/test_operations.pytdst5s(t__name__t __module__R R!R"(((s</Users/spulec/Development/freezegun/tests/test_operations.pyR0s  s2012-01-14 2:00:00cCsjtjjdtƒƒ}|tjdddddtƒƒksEt‚|jƒtdd ƒksft‚dS( NRiÜiiiRii<iiiPF(RRRR R R(R((s</Users/spulec/Development/freezegun/tests/test_operations.pyttest_datetime_timezone_real9s-t tz_offsetiüÿÿÿcCsjtjjdtƒƒ}|tjdddddtƒƒksEt‚|jƒtdd ƒksft‚dS( NRiÜiiiRii<iiiPF(RRRR R R(R((s</Users/spulec/Development/freezegun/tests/test_operations.pyt'test_datetime_timezone_real_with_offset@s-s2012-01-14 00:00:00cCsCtjjdtƒƒ}|jtƒƒ}tj|ƒs?t‚dS(NR(RRRt astimezoneRRR (Rt converted((s</Users/spulec/Development/freezegun/tests/test_operations.pyttest_astimezoneGscCsptjjƒ}|jddƒ}tj|ƒs6t‚tjjƒ}|jddƒ}tj|ƒslt‚dS(NtyeariÝ( RRtreplaceRRR R R R (Rt modified_timeR t modified_date((s</Users/spulec/Development/freezegun/tests/test_operations.pyt test_replaceNs (Rt freezegunRtdateutil.relativedeltaRRRttestsRRRRRR%R'R*R/(((s</Users/spulec/Development/freezegun/tests/test_operations.pyts  freezegun-0.3.5/tests/test_pickle.py0000644000076500000240000000371312557140450020160 0ustar spulecstaff00000000000000import datetime import pickle from freezegun import freeze_time def assert_pickled_datetimes_equal_original(): min_datetime = datetime.datetime.min max_datetime = datetime.datetime.max min_date = datetime.date.min max_date = datetime.date.max now = datetime.datetime.now() today = datetime.date.today() utc_now = datetime.datetime.utcnow() assert pickle.loads(pickle.dumps(min_datetime)) == min_datetime assert pickle.loads(pickle.dumps(max_datetime)) == max_datetime assert pickle.loads(pickle.dumps(min_date)) == min_date assert pickle.loads(pickle.dumps(max_date)) == max_date assert pickle.loads(pickle.dumps(now)) == now assert pickle.loads(pickle.dumps(today)) == today assert pickle.loads(pickle.dumps(utc_now)) == utc_now def test_pickle(): freezer = freeze_time("2012-01-14") freezer.start() assert_pickled_datetimes_equal_original() freezer.stop() assert_pickled_datetimes_equal_original() def test_pickle_real_datetime(): real_datetime = datetime.datetime(1970, 2, 1) pickle.loads(pickle.dumps(real_datetime)) == real_datetime freezer = freeze_time("1970-01-01") freezer.start() fake_datetime = datetime.datetime.now() assert pickle.loads(pickle.dumps(fake_datetime)) == fake_datetime pickle.loads(pickle.dumps(real_datetime)) freezer.stop() assert pickle.loads(pickle.dumps(fake_datetime)) == fake_datetime assert pickle.loads(pickle.dumps(real_datetime)) == real_datetime def test_pickle_real_date(): real_date = datetime.date(1970, 2, 1) assert pickle.loads(pickle.dumps(real_date)) == real_date freezer = freeze_time("1970-01-01") freezer.start() fake_date = datetime.datetime.now() assert pickle.loads(pickle.dumps(fake_date)) == fake_date pickle.loads(pickle.dumps(real_date)) freezer.stop() assert pickle.loads(pickle.dumps(fake_date)) == fake_date assert pickle.loads(pickle.dumps(real_date)) == real_date freezegun-0.3.5/tests/test_pickle.pyc0000644000076500000240000000442312505565146020330 0ustar spulecstaff00000000000000ó Y âTc@sPddlZddlZddlmZd„Zd„Zd„Zd„ZdS(iÿÿÿÿN(t freeze_timecCs]tjj}tjj}tjj}tjj}tjjƒ}tjjƒ}tjjƒ}tjtj |ƒƒ|kst ‚tjtj |ƒƒ|ks¥t ‚tjtj |ƒƒ|ksÉt ‚tjtj |ƒƒ|ksít ‚tjtj |ƒƒ|kst ‚tjtj |ƒƒ|ks5t ‚tjtj |ƒƒ|ksYt ‚dS(N( tdatetimetmintmaxtdatetnowttodaytutcnowtpickletloadstdumpstAssertionError(t min_datetimet max_datetimetmin_datetmax_dateRRtutc_now((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyt'assert_pickled_datetimes_equal_originals    $$$$$$cCs2tdƒ}|jƒtƒ|jƒtƒdS(Ns 2012-01-14(RtstartRtstop(tfreezer((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyt test_pickles    cCsætjdddƒ}tjtj|ƒƒ|ktdƒ}|jƒtjjƒ}tjtj|ƒƒ|kszt‚tjtj|ƒƒ|jƒtjtj|ƒƒ|ks¾t‚tjtj|ƒƒ|ksât‚dS(Ni²iis 1970-01-01( RRR R RRRR R(t real_datetimeRt fake_datetime((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyttest_pickle_real_datetime!s  $ $cCsîtjdddƒ}tjtj|ƒƒ|ks9t‚tdƒ}|jƒtjjƒ}tjtj|ƒƒ|ks‚t‚tjtj|ƒƒ|j ƒtjtj|ƒƒ|ksÆt‚tjtj|ƒƒ|ksêt‚dS(Ni²iis 1970-01-01( RRRR R R RRRR(t real_dateRt fake_date((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyttest_pickle_real_date0s$  $ $(RRt freezegunRRRRR(((s8/Users/spulec/Development/freezegun/tests/test_pickle.pyts    freezegun-0.3.5/tests/test_sqlite2.pyc0000644000076500000240000000117212323365141020431 0ustar spulecstaff00000000000000ó ZêMSc@sAddlZddlmZddlZedƒd„ƒZdS(iÿÿÿÿN(t freeze_times 2013-01-01cCsEtjdƒ}ddl}|jƒ|jdtjjƒfƒdS(Ns/tmp/fooiÿÿÿÿsselect ?(tsqlite3tconnecttpdbt set_tracetexecutetdatetimetnow(tdbR((s9/Users/spulec/Development/freezegun/tests/test_sqlite2.pyttest_fake_datetime_inserts (Rt freezegunRRR (((s9/Users/spulec/Development/freezegun/tests/test_sqlite2.pyts  freezegun-0.3.5/tests/test_sqlite3.py0000644000076500000240000000056712323367423020303 0ustar spulecstaff00000000000000import datetime from freezegun import freeze_time import sqlite3 @freeze_time("2013-01-01") def test_fake_datetime_select(): db = sqlite3.connect("/tmp/foo") db.execute("""select ?""", (datetime.datetime.now(),)) @freeze_time("2013-01-01") def test_fake_date_select(): db = sqlite3.connect("/tmp/foo") db.execute("""select ?""", (datetime.date.today(),)) freezegun-0.3.5/tests/test_sqlite3.pyc0000644000076500000240000000154612416600237020440 0ustar spulecstaff00000000000000ó ïMSc@sVddlZddlmZddlZedƒd„ƒZedƒd„ƒZdS(iÿÿÿÿN(t freeze_times 2013-01-01cCs/tjdƒ}|jdtjjƒfƒdS(Ns/tmp/foosselect ?(tsqlite3tconnecttexecutetdatetimetnow(tdb((s9/Users/spulec/Development/freezegun/tests/test_sqlite3.pyttest_fake_datetime_selectscCs/tjdƒ}|jdtjjƒfƒdS(Ns/tmp/foosselect ?(RRRRtdatettoday(R((s9/Users/spulec/Development/freezegun/tests/test_sqlite3.pyttest_fake_date_select s(Rt freezegunRRRR (((s9/Users/spulec/Development/freezegun/tests/test_sqlite3.pyts  freezegun-0.3.5/tests/test_test.pyc0000644000076500000240000000112112476173765020041 0ustar spulecstaff00000000000000ó ò÷øTc@s¦ddlmZddlZddlmZmZddlmZdZeddeƒFedƒZ ejj ƒZ e e ƒejj e ƒZ e e ƒWdQXdS( iÿÿÿÿ(tprint_functionN(tgettzttzlocal(t freeze_timeis2014-04-26 12:01:00t tz_offsets Europe/London( t __future__Rtdatetimet dateutil.tzRRt freezegunRt TZ_OFFSETttimezonetnowttimetprint(((s6/Users/spulec/Development/freezegun/tests/test_test.pyts   freezegun-0.3.5/tests/test_ticking.py0000644000076500000240000000213612560662146020344 0ustar spulecstaff00000000000000import datetime import time import mock from freezegun import freeze_time from tests import utils @utils.cpython_only def test_ticking_datetime(): with freeze_time("Jan 14th, 2012", tick=True): assert datetime.datetime.now() > datetime.datetime(2012, 1, 14) @utils.cpython_only def test_ticking_date(): with freeze_time("Jan 14th, 2012, 23:59:59.9999999", tick=True): assert datetime.date.today() == datetime.date(2012, 1, 15) @utils.cpython_only def test_ticking_time(): with freeze_time("Jan 14th, 2012, 23:59:59", tick=True): assert time.time() > 1326585599.0 @mock.patch('freezegun.api._is_cpython', lambda: False) def test_pypy_compat(): try: freeze_time("Jan 14th, 2012, 23:59:59", tick=True) except SystemError: pass else: raise AssertionError("tick=True should not error on cpython") @mock.patch('freezegun.api._is_cpython', lambda: True) def test_non_pypy_compat(): try: freeze_time("Jan 14th, 2012, 23:59:59", tick=True) except Exception: raise AssertionError("tick=True should error on non cpython") freezegun-0.3.5/tests/utils.py0000644000076500000240000000070212560662146017012 0ustar spulecstaff00000000000000from functools import wraps from nose.plugins import skip from freezegun.api import FakeDate, FakeDatetime, _is_cpython def is_fake_date(obj): return obj.__class__ is FakeDate def is_fake_datetime(obj): return obj.__class__ is FakeDatetime def cpython_only(func): @wraps(func) def wrapper(*args): if not _is_cpython(): raise skip.SkipTest("tick=True on pypy") return func(*args) return wrapper freezegun-0.3.5/tests/utils.pyc0000644000076500000240000000112112433262640017143 0ustar spulecstaff00000000000000ó emTc@s,ddlmZmZd„Zd„ZdS(iÿÿÿÿ(tFakeDatet FakeDatetimecCs |jtkS(N(t __class__R(tobj((s2/Users/spulec/Development/freezegun/tests/utils.pyt is_fake_datescCs |jtkS(N(RR(R((s2/Users/spulec/Development/freezegun/tests/utils.pytis_fake_datetimesN(t freezegun.apiRRRR(((s2/Users/spulec/Development/freezegun/tests/utils.pyts