Commit bffec654 authored by Federico Ceratto's avatar Federico Ceratto

New upstream version 0.3.7

parent 2bf9719f
include README.rst LICENSE AUTHORS.rst
recursive-include tests *
global-exclude __pycache__
global-exclude *.py[co]
Metadata-Version: 1.1
Name: freezegun
Version: 0.3.6
Version: 0.3.7
Summary: Let your Python tests travel through time
Home-page: https://github.com/spulec/freezegun
Author: Steve Pulec
......
......@@ -26,7 +26,7 @@ Decorator
@freeze_time("2012-01-14")
def test():
assert datetime.datetime.now() == datetime.datetime(2012, 01, 14)
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
# Or a unittest TestCase - freezes for every test, from the start of setUpClass to the end of tearDownClass
......@@ -40,7 +40,7 @@ Decorator
@freeze_time("2012-01-14")
class Tester(object):
def test_the_class(self):
assert datetime.datetime.now() == datetime.datetime(2012, 01, 14)
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
Context Manager
~~~~~~~~~~~~~~~
......@@ -50,10 +50,10 @@ Context Manager
from freezegun import freeze_time
def test():
assert datetime.datetime.now() != datetime.datetime(2012, 01, 14)
assert datetime.datetime.now() != datetime.datetime(2012, 1, 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)
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
assert datetime.datetime.now() != datetime.datetime(2012, 1, 14)
Raw use
~~~~~~~
......@@ -64,7 +64,7 @@ Raw use
freezer = freeze_time("2012-01-14 12:00:01")
freezer.start()
assert datetime.datetime.now() == datetime.datetime(2012, 01, 14, 12, 00, 01)
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14, 12, 0, 1)
freezer.stop()
Timezones
......@@ -76,11 +76,11 @@ Timezones
@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)
assert datetime.datetime.utcnow() == datetime.datetime(2012, 1, 14, 3, 21, 34)
assert datetime.datetime.now() == datetime.datetime(2012, 1, 13, 23, 21, 34)
# datetime.date.today() uses local time
assert datetime.date.today() == datetime.date(2012, 01, 13)
assert datetime.date.today() == datetime.date(2012, 1, 13)
Nice inputs
~~~~~~~~~~~
......@@ -91,7 +91,7 @@ FreezeGun uses dateutil behind the scenes so you can have nice-looking datetimes
@freeze_time("Jan 14th, 2012")
def test_nice_datetime():
assert datetime.datetime.now() == datetime.datetime(2012, 01, 14)
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
`tick` argument
~~~~~~~~~~~
......@@ -104,7 +104,7 @@ parameters which will keep time stopped.
@freeze_time("Jan 14th, 2020", tick=True)
def test_nice_datetime():
assert datetime.datetime.now() > datetime.datetime(2020, 01, 14)
assert datetime.datetime.now() > datetime.datetime(2020, 1, 14)
Manual ticks
~~~~~~~~~~~~
......
Metadata-Version: 1.1
Name: freezegun
Version: 0.3.6
Version: 0.3.7
Summary: Let your Python tests travel through time
Home-page: https://github.com/spulec/freezegun
Author: Steve Pulec
......
......@@ -12,37 +12,14 @@ freezegun.egg-info/dependency_links.txt
freezegun.egg-info/requires.txt
freezegun.egg-info/top_level.txt
tests/__init__.py
tests/__init__.pyc
tests/another_module.py
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/test_ticking.pyc
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.pyc
\ No newline at end of file
tests/test_utils.py
tests/utils.py
\ No newline at end of file
......@@ -9,7 +9,7 @@ freezegun
from .api import freeze_time
__title__ = 'freezegun'
__version__ = '0.3.6'
__version__ = '0.3.7'
__author__ = 'Steve Pulec'
__license__ = 'Apache License 2.0'
__copyright__ = 'Copyright 2012 Steve Pulec'
......
......@@ -29,7 +29,7 @@ def with_metaclass(meta, *bases):
_is_cpython = (
hasattr(platform, 'python_implementation') and
platform.python_implementation().lower == "cpython"
platform.python_implementation().lower() == "cpython"
)
......@@ -261,6 +261,8 @@ class FrozenDateTimeFactory(object):
class _freeze_time(object):
def __init__(self, time_to_freeze_str, tz_offset, ignore, tick):
if time_to_freeze_str is None:
time_to_freeze = datetime.datetime.utcnow()
if isinstance(time_to_freeze_str, datetime.datetime):
time_to_freeze = time_to_freeze_str
elif isinstance(time_to_freeze_str, datetime.date):
......@@ -457,7 +459,7 @@ class _freeze_time(object):
return wrapper
def freeze_time(time_to_freeze, tz_offset=0, ignore=None, tick=False):
def freeze_time(time_to_freeze=None, tz_offset=0, ignore=None, tick=False):
# Python3 doesn't have basestring, but it does have str.
try:
string_type = basestring
......@@ -465,7 +467,7 @@ def freeze_time(time_to_freeze, tz_offset=0, ignore=None, tick=False):
string_type = str
if not isinstance(time_to_freeze, (string_type, datetime.date)):
raise TypeError(('freeze_time() expected a string, date instance, or '
raise TypeError(('freeze_time() expected None, 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')
......
......@@ -13,7 +13,7 @@ else:
setup(
name='freezegun',
version='0.3.6',
version='0.3.7',
description='Let your Python tests travel through time',
author='Steve Pulec',
author_email='spulec@gmail',
......
import mock
from nose.plugins import skip
from freezegun import api
from tests import utils
try:
reload
except NameError:
try:
from importlib import reload
except ImportError:
from imp import reload
@mock.patch('platform.python_implementation', lambda: 'CPython')
def test_should_not_skip_cpython():
reload(api)
reload(utils)
function_mock = mock.MagicMock(__name__='function')
try:
utils.cpython_only(function_mock)()
except skip.SkipTest:
raise AssertionError("Test was skipped in CPython")
assert function_mock.called
@mock.patch('platform.python_implementation', lambda: 'not-CPython')
def test_should_skip_non_cpython():
reload(api)
reload(utils)
function_mock = mock.MagicMock(__name__='function', skipped=False)
try:
utils.cpython_only(function_mock)()
except skip.SkipTest:
function_mock.skipped = True
assert not function_mock.called
assert function_mock.skipped
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment