This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Frozendate suspends time while your tests run.

Frozendate mocks datetime.datetime and datetime.date to provide known times when testing.

Usage

import frozendate

with frozendate.freeze(1999, 1, 1):
    party_like_its_1999()

# freeze relative freezes time relative to the current date...
with freeze_relative(days=-1):
    assert all_my_troubles_seemed_so_far_away()

with freeze(1999, 12, 31):
    # ...or relative to the previous freeze
    with freeze_relative(days=1):
        print "happy new year!"

Normally time doesn’t actually stop when you use freeze – it just starts again from the fixed point you specify, eg:

>>> import frozendate
>>> import datetime
>>> with frozendate.freeze(2000, 1, 1):
...     print datetime.now().replace(microsecond=0)
...     time.sleep(1)
...     print datetime.now().replace(microsecond=0)
...
2000-01-01 00:00:00
2000-01-01 00:00:01

But you can always get the same value back if you pass hard=True:

>>> with frozendate.freeze(2000, 1, 1, hard=True):
...     print datetime.now().replace(microsecond=0)
...     time.sleep(1)
...     print datetime.now().replace(microsecond=0)
...
2000-01-01 00:00:00
2000-01-01 00:00:00

Instead of a context manager there are also regular patch and unpatch functions. These are useful in test case setup/teardown methods:

def setUp(self):
    frozendate.patch(2000, 1, 1)

def tearDown(self):
    frozendate.unpatch()

When you call freeze or patch, it freezes time for all modules found in sys.modules. Sometimes you want to restrict to a few named modules:

frozendate.freeze(modules=['mypackage.mymodule'])

Or patch everything, but exclude a few modules that need the real datetime still:

frozendate.freeze(dontpatch=['somemodule', 'someotherpackage'])

CHANGELOG

Version 0.1.2

  • Add support for freezing datetime.utcnow()

Version 0.1.1

  • Fix for ImportErrors when used with six

Version 0.1

  • Initial release
Release History

Release History

0.1.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
frozendate-0.1.2.tar.gz (5.1 kB) Copy SHA256 Checksum SHA256 Source Feb 13, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting