Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepsy90 committed Jun 8, 2018
2 parents 3b48ac0 + 1a6c814 commit 1e2c2c7
Show file tree
Hide file tree
Showing 14 changed files with 365 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ build
*.tox
dist
*.pyc
venv/
.idea
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python:
- 3.4
- 3.6
- pypy3.3-5.2-alpha1
- 3.7-dev
script: make travis
install:
- pip install .
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Patches and Suggestions
- `Adam Johnson <https://github.com/adamchainz>`_
- `Alex Ehlke <https://github.com/aehlke>`_
- `James Lu <github.com/CrazyPython>`_
- `Dan Elkis <github.com/rinslow>`_
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Freezegun Changelog
Latest
------

0.3.10
------

* Performance improvements
* Coroutine support
*

0.3.9
-----

Expand Down
11 changes: 11 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ Timezones
# datetime.date.today() uses local time
assert datetime.date.today() == datetime.date(2012, 1, 13)
@freeze_time("2012-01-14 03:21:34", tz_offset=-datetime.timedelta(hours=3, minutes=30))
def test_timedelta_offset():
assert datetime.datetime.now() == datetime.datetime(2012, 1, 13, 23, 51, 34)
Nice inputs
~~~~~~~~~~~

Expand Down Expand Up @@ -187,6 +191,13 @@ Freezegun allows moving time to specific dates.
frozen_datetime.move_to(initial_datetime)
assert frozen_datetime() == initial_datetime
@freeze_time("2012-01-14", as_arg=True)
def test(frozen_time):
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
frozen_time.move_to("2014-02-12")
assert datetime.datetime.now() == datetime.datetime(2014, 2, 12)
Parameter for ``move_to`` can be any valid ``freeze_time`` date (string, date, datetime).


Expand Down
2 changes: 1 addition & 1 deletion freezegun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .api import freeze_time

__title__ = 'freezegun'
__version__ = '0.3.9'
__version__ = '0.3.10'
__author__ = 'Steve Pulec'
__license__ = 'Apache License 2.0'
__copyright__ = 'Copyright 2012 Steve Pulec'
Expand Down
17 changes: 17 additions & 0 deletions freezegun/_async.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import functools

import asyncio


def wrap_coroutine(api, coroutine):
@functools.wraps(coroutine)
@asyncio.coroutine
def wrapper(*args, **kwargs):
with api as time_factory:
if api.as_arg:
result = yield from coroutine(time_factory, *args, **kwargs)
else:
result = yield from coroutine(*args, **kwargs)
return result

return wrapper

0 comments on commit 1e2c2c7

Please sign in to comment.