Add files using upload-large-folder tool
Browse files- .cache/pip/http-v2/0/2/f/8/e/02f8e820ca8231526982c4a2b93baef519d0948ff85c925acd226f06 +0 -0
- .cache/pip/http-v2/0/2/f/8/e/02f8e820ca8231526982c4a2b93baef519d0948ff85c925acd226f06.body +0 -0
- .cache/pip/http-v2/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8 +0 -0
- .cache/pip/http-v2/0/b/4/2/5/0b42568201c5e6708aa0fcd89da5baf0ae87e48bf530c999041920bc +0 -0
- .cache/pip/http-v2/0/c/2/1/8/0c218d526767991766d9b365a4f3e4449ce3579fd8b0f96a707d5a52 +0 -0
- .cache/pip/http-v2/0/c/2/1/8/0c218d526767991766d9b365a4f3e4449ce3579fd8b0f96a707d5a52.body +0 -0
- .cache/pip/http-v2/0/c/b/f/f/0cbfff75291f05c16794a4e2c6c63bcb459c017712a63fb22148cd22.body +0 -0
- .cache/pip/http-v2/0/e/d/3/3/0ed336d749e009fe1267c844e36c442e5b3dc645d5eb9865c545b81a +0 -0
- .cache/pip/http-v2/0/e/d/3/3/0ed336d749e009fe1267c844e36c442e5b3dc645d5eb9865c545b81a.body +0 -0
- .cache/pip/http-v2/0/f/a/e/c/0faec10fc908d92f19ad98c40f513a1781ae2d868b0add6bff108aff +0 -0
- .cache/pip/http-v2/0/f/a/e/c/0faec10fc908d92f19ad98c40f513a1781ae2d868b0add6bff108aff.body +0 -0
- .cache/pip/http-v2/3/3/9/7/4/33974f84394d9a943f68359da08431dab4af9f86c33962982ea21b5f +0 -0
- .cache/pip/http-v2/3/3/9/7/4/33974f84394d9a943f68359da08431dab4af9f86c33962982ea21b5f.body +0 -0
- .cache/pip/http-v2/3/6/5/e/a/365ea28f603b8ce12b6f327aebb85d07917fc12688bd8ca440f6cd58.body +0 -0
- .cache/pip/http-v2/3/a/3/e/8/3a3e8ead5a1091f46e8776fafa4d27f25898f409e8cda3b8b449e77d +0 -0
- .cache/pip/http-v2/3/a/3/e/8/3a3e8ead5a1091f46e8776fafa4d27f25898f409e8cda3b8b449e77d.body +385 -0
- .cache/pip/http-v2/3/c/e/7/7/3ce770df07ea321ab056bed31a67391a50e82aea9460d349fd057276 +0 -0
- .cache/pip/http-v2/3/c/e/7/7/3ce770df07ea321ab056bed31a67391a50e82aea9460d349fd057276.body +107 -0
- .cache/pip/http-v2/3/d/0/1/0/3d010bbe832a78f7d62973a62c254ff82b3b6531c47ffeeeb5a7dd5e +0 -0
- .cache/pip/http-v2/3/d/0/1/0/3d010bbe832a78f7d62973a62c254ff82b3b6531c47ffeeeb5a7dd5e.body +0 -0
.cache/pip/http-v2/0/2/f/8/e/02f8e820ca8231526982c4a2b93baef519d0948ff85c925acd226f06
ADDED
|
Binary file (1.78 kB). View file
|
|
|
.cache/pip/http-v2/0/2/f/8/e/02f8e820ca8231526982c4a2b93baef519d0948ff85c925acd226f06.body
ADDED
|
Binary file (45.1 kB). View file
|
|
|
.cache/pip/http-v2/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8
ADDED
|
Binary file (1.78 kB). View file
|
|
|
.cache/pip/http-v2/0/b/4/2/5/0b42568201c5e6708aa0fcd89da5baf0ae87e48bf530c999041920bc
ADDED
|
Binary file (1.12 kB). View file
|
|
|
.cache/pip/http-v2/0/c/2/1/8/0c218d526767991766d9b365a4f3e4449ce3579fd8b0f96a707d5a52
ADDED
|
Binary file (1.85 kB). View file
|
|
|
.cache/pip/http-v2/0/c/2/1/8/0c218d526767991766d9b365a4f3e4449ce3579fd8b0f96a707d5a52.body
ADDED
|
Binary file (46 kB). View file
|
|
|
.cache/pip/http-v2/0/c/b/f/f/0cbfff75291f05c16794a4e2c6c63bcb459c017712a63fb22148cd22.body
ADDED
|
Binary file (7.48 kB). View file
|
|
|
.cache/pip/http-v2/0/e/d/3/3/0ed336d749e009fe1267c844e36c442e5b3dc645d5eb9865c545b81a
ADDED
|
Binary file (1.15 kB). View file
|
|
|
.cache/pip/http-v2/0/e/d/3/3/0ed336d749e009fe1267c844e36c442e5b3dc645d5eb9865c545b81a.body
ADDED
|
Binary file (20.5 kB). View file
|
|
|
.cache/pip/http-v2/0/f/a/e/c/0faec10fc908d92f19ad98c40f513a1781ae2d868b0add6bff108aff
ADDED
|
Binary file (1.78 kB). View file
|
|
|
.cache/pip/http-v2/0/f/a/e/c/0faec10fc908d92f19ad98c40f513a1781ae2d868b0add6bff108aff.body
ADDED
|
Binary file (6.39 kB). View file
|
|
|
.cache/pip/http-v2/3/3/9/7/4/33974f84394d9a943f68359da08431dab4af9f86c33962982ea21b5f
ADDED
|
Binary file (1.78 kB). View file
|
|
|
.cache/pip/http-v2/3/3/9/7/4/33974f84394d9a943f68359da08431dab4af9f86c33962982ea21b5f.body
ADDED
|
Binary file (6.94 kB). View file
|
|
|
.cache/pip/http-v2/3/6/5/e/a/365ea28f603b8ce12b6f327aebb85d07917fc12688bd8ca440f6cd58.body
ADDED
|
Binary file (28.9 kB). View file
|
|
|
.cache/pip/http-v2/3/a/3/e/8/3a3e8ead5a1091f46e8776fafa4d27f25898f409e8cda3b8b449e77d
ADDED
|
Binary file (1.17 kB). View file
|
|
|
.cache/pip/http-v2/3/a/3/e/8/3a3e8ead5a1091f46e8776fafa4d27f25898f409e8cda3b8b449e77d.body
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ary: Let your Python tests travel through time
|
| 5 |
+
Home-page: https://github.com/spulec/freezegun
|
| 6 |
+
Author: Steve Pulec
|
| 7 |
+
Author-email: spulec@gmail.com
|
| 8 |
+
License: Apache-2.0
|
| 9 |
+
Project-URL: Bug Tracker, https://github.com/spulec/freezegun/issues
|
| 10 |
+
Project-URL: Changes, https://github.com/spulec/freezegun/blob/master/CHANGELOG
|
| 11 |
+
Project-URL: Documentation, https://github.com/spulec/freezegun/blob/master/README.rst
|
| 12 |
+
Project-URL: Source Code, https://github.com/spulec/freezegun
|
| 13 |
+
Classifier: Programming Language :: Python :: 3
|
| 14 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 20 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 21 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 22 |
+
Requires-Python: >=3.8
|
| 23 |
+
License-File: LICENSE
|
| 24 |
+
License-File: AUTHORS.rst
|
| 25 |
+
Requires-Dist: python-dateutil>=2.7
|
| 26 |
+
Dynamic: license-file
|
| 27 |
+
|
| 28 |
+
FreezeGun: Let your Python tests travel through time
|
| 29 |
+
====================================================
|
| 30 |
+
|
| 31 |
+
.. image:: https://img.shields.io/pypi/v/freezegun.svg
|
| 32 |
+
:target: https://pypi.python.org/pypi/freezegun/
|
| 33 |
+
.. image:: https://github.com/spulec/freezegun/workflows/CI/badge.svg
|
| 34 |
+
:target: https://github.com/spulec/freezegun/actions
|
| 35 |
+
.. image:: https://coveralls.io/repos/spulec/freezegun/badge.svg?branch=master
|
| 36 |
+
:target: https://coveralls.io/r/spulec/freezegun
|
| 37 |
+
|
| 38 |
+
FreezeGun is a library that allows your Python tests to travel through time by mocking the datetime module.
|
| 39 |
+
|
| 40 |
+
Usage
|
| 41 |
+
-----
|
| 42 |
+
|
| 43 |
+
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. time.monotonic() and time.perf_counter() will also be frozen, but as usual it makes no guarantees about their absolute value, only their changes over time.
|
| 44 |
+
|
| 45 |
+
Decorator
|
| 46 |
+
~~~~~~~~~
|
| 47 |
+
|
| 48 |
+
.. code-block:: python
|
| 49 |
+
|
| 50 |
+
from freezegun import freeze_time
|
| 51 |
+
import datetime
|
| 52 |
+
import unittest
|
| 53 |
+
|
| 54 |
+
# Freeze time for a pytest style test:
|
| 55 |
+
|
| 56 |
+
@freeze_time("2012-01-14")
|
| 57 |
+
def test():
|
| 58 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
|
| 59 |
+
|
| 60 |
+
# Or a unittest TestCase - freezes for every test, and set up and tear down code
|
| 61 |
+
|
| 62 |
+
@freeze_time("1955-11-12")
|
| 63 |
+
class MyTests(unittest.TestCase):
|
| 64 |
+
def test_the_class(self):
|
| 65 |
+
assert datetime.datetime.now() == datetime.datetime(1955, 11, 12)
|
| 66 |
+
|
| 67 |
+
# Or any other class - freezes around each callable (may not work in every case)
|
| 68 |
+
|
| 69 |
+
@freeze_time("2012-01-14")
|
| 70 |
+
class Tester(object):
|
| 71 |
+
def test_the_class(self):
|
| 72 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
|
| 73 |
+
|
| 74 |
+
# Or method decorator, might also pass frozen time object as kwarg
|
| 75 |
+
|
| 76 |
+
class TestUnitTestMethodDecorator(unittest.TestCase):
|
| 77 |
+
@freeze_time('2013-04-09')
|
| 78 |
+
def test_method_decorator_works_on_unittest(self):
|
| 79 |
+
self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today())
|
| 80 |
+
|
| 81 |
+
@freeze_time('2013-04-09', as_kwarg='frozen_time')
|
| 82 |
+
def test_method_decorator_works_on_unittest(self, frozen_time):
|
| 83 |
+
self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today())
|
| 84 |
+
self.assertEqual(datetime.date(2013, 4, 9), frozen_time.time_to_freeze.date())
|
| 85 |
+
|
| 86 |
+
@freeze_time('2013-04-09', as_kwarg='hello')
|
| 87 |
+
def test_method_decorator_works_on_unittest(self, **kwargs):
|
| 88 |
+
self.assertEqual(datetime.date(2013, 4, 9), datetime.date.today())
|
| 89 |
+
self.assertEqual(datetime.date(2013, 4, 9), kwargs.get('hello').time_to_freeze.date())
|
| 90 |
+
|
| 91 |
+
Context manager
|
| 92 |
+
~~~~~~~~~~~~~~~
|
| 93 |
+
|
| 94 |
+
.. code-block:: python
|
| 95 |
+
|
| 96 |
+
from freezegun import freeze_time
|
| 97 |
+
|
| 98 |
+
def test():
|
| 99 |
+
assert datetime.datetime.now() != datetime.datetime(2012, 1, 14)
|
| 100 |
+
with freeze_time("2012-01-14"):
|
| 101 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
|
| 102 |
+
assert datetime.datetime.now() != datetime.datetime(2012, 1, 14)
|
| 103 |
+
|
| 104 |
+
Raw use
|
| 105 |
+
~~~~~~~
|
| 106 |
+
|
| 107 |
+
.. code-block:: python
|
| 108 |
+
|
| 109 |
+
from freezegun import freeze_time
|
| 110 |
+
|
| 111 |
+
freezer = freeze_time("2012-01-14 12:00:01")
|
| 112 |
+
freezer.start()
|
| 113 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14, 12, 0, 1)
|
| 114 |
+
freezer.stop()
|
| 115 |
+
|
| 116 |
+
Timezones
|
| 117 |
+
~~~~~~~~~
|
| 118 |
+
|
| 119 |
+
.. code-block:: python
|
| 120 |
+
|
| 121 |
+
from freezegun import freeze_time
|
| 122 |
+
|
| 123 |
+
@freeze_time("2012-01-14 03:21:34", tz_offset=-4)
|
| 124 |
+
def test():
|
| 125 |
+
assert datetime.datetime.utcnow() == datetime.datetime(2012, 1, 14, 3, 21, 34)
|
| 126 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 13, 23, 21, 34)
|
| 127 |
+
|
| 128 |
+
# datetime.date.today() uses local time
|
| 129 |
+
assert datetime.date.today() == datetime.date(2012, 1, 13)
|
| 130 |
+
|
| 131 |
+
@freeze_time("2012-01-14 03:21:34", tz_offset=-datetime.timedelta(hours=3, minutes=30))
|
| 132 |
+
def test_timedelta_offset():
|
| 133 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 13, 23, 51, 34)
|
| 134 |
+
|
| 135 |
+
Nice inputs
|
| 136 |
+
~~~~~~~~~~~
|
| 137 |
+
|
| 138 |
+
FreezeGun uses dateutil behind the scenes so you can have nice-looking datetimes.
|
| 139 |
+
|
| 140 |
+
.. code-block:: python
|
| 141 |
+
|
| 142 |
+
@freeze_time("Jan 14th, 2012")
|
| 143 |
+
def test_nice_datetime():
|
| 144 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
|
| 145 |
+
|
| 146 |
+
Function and generator objects
|
| 147 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 148 |
+
|
| 149 |
+
FreezeGun is able to handle function and generator objects.
|
| 150 |
+
|
| 151 |
+
.. code-block:: python
|
| 152 |
+
|
| 153 |
+
def test_lambda():
|
| 154 |
+
with freeze_time(lambda: datetime.datetime(2012, 1, 14)):
|
| 155 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
|
| 156 |
+
|
| 157 |
+
def test_generator():
|
| 158 |
+
datetimes = (datetime.datetime(year, 1, 1) for year in range(2010, 2012))
|
| 159 |
+
|
| 160 |
+
with freeze_time(datetimes):
|
| 161 |
+
assert datetime.datetime.now() == datetime.datetime(2010, 1, 1)
|
| 162 |
+
|
| 163 |
+
with freeze_time(datetimes):
|
| 164 |
+
assert datetime.datetime.now() == datetime.datetime(2011, 1, 1)
|
| 165 |
+
|
| 166 |
+
# The next call to freeze_time(datetimes) would raise a StopIteration exception.
|
| 167 |
+
|
| 168 |
+
``tick`` argument
|
| 169 |
+
~~~~~~~~~~~~~~~~~
|
| 170 |
+
|
| 171 |
+
FreezeGun has an additional ``tick`` argument which will restart time at the given
|
| 172 |
+
value, but then time will keep ticking. This is an alternative to the default
|
| 173 |
+
parameters which will keep time stopped.
|
| 174 |
+
|
| 175 |
+
.. code-block:: python
|
| 176 |
+
|
| 177 |
+
@freeze_time("Jan 14th, 2020", tick=True)
|
| 178 |
+
def test_nice_datetime():
|
| 179 |
+
assert datetime.datetime.now() > datetime.datetime(2020, 1, 14)
|
| 180 |
+
|
| 181 |
+
``auto_tick_seconds`` argument
|
| 182 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 183 |
+
|
| 184 |
+
FreezeGun has an additional ``auto_tick_seconds`` argument which will autoincrement the
|
| 185 |
+
value every time by the given amount from the start value. This is an alternative to the default
|
| 186 |
+
parameters which will keep time stopped. Note that given ``auto_tick_seconds`` the ``tick`` parameter will be ignored.
|
| 187 |
+
|
| 188 |
+
.. code-block:: python
|
| 189 |
+
|
| 190 |
+
@freeze_time("Jan 14th, 2020", auto_tick_seconds=15)
|
| 191 |
+
def test_nice_datetime():
|
| 192 |
+
first_time = datetime.datetime.now()
|
| 193 |
+
auto_incremented_time = datetime.datetime.now()
|
| 194 |
+
assert first_time + datetime.timedelta(seconds=15) == auto_incremented_time
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
Manual ticks
|
| 198 |
+
~~~~~~~~~~~~
|
| 199 |
+
|
| 200 |
+
FreezeGun allows for the time to be manually forwarded as well.
|
| 201 |
+
|
| 202 |
+
.. code-block:: python
|
| 203 |
+
|
| 204 |
+
def test_manual_tick():
|
| 205 |
+
initial_datetime = datetime.datetime(year=1, month=7, day=12,
|
| 206 |
+
hour=15, minute=6, second=3)
|
| 207 |
+
with freeze_time(initial_datetime) as frozen_datetime:
|
| 208 |
+
assert frozen_datetime() == initial_datetime
|
| 209 |
+
|
| 210 |
+
frozen_datetime.tick()
|
| 211 |
+
initial_datetime += datetime.timedelta(seconds=1)
|
| 212 |
+
assert frozen_datetime() == initial_datetime
|
| 213 |
+
|
| 214 |
+
frozen_datetime.tick(delta=datetime.timedelta(seconds=10))
|
| 215 |
+
initial_datetime += datetime.timedelta(seconds=10)
|
| 216 |
+
assert frozen_datetime() == initial_datetime
|
| 217 |
+
|
| 218 |
+
.. code-block:: python
|
| 219 |
+
|
| 220 |
+
def test_monotonic_manual_tick():
|
| 221 |
+
initial_datetime = datetime.datetime(year=1, month=7, day=12,
|
| 222 |
+
hour=15, minute=6, second=3)
|
| 223 |
+
with freeze_time(initial_datetime) as frozen_datetime:
|
| 224 |
+
monotonic_t0 = time.monotonic()
|
| 225 |
+
frozen_datetime.tick(1.0)
|
| 226 |
+
monotonic_t1 = time.monotonic()
|
| 227 |
+
assert monotonic_t1 == monotonic_t0 + 1.0
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
Moving time to specify datetime
|
| 231 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 232 |
+
|
| 233 |
+
FreezeGun allows moving time to specific dates.
|
| 234 |
+
|
| 235 |
+
.. code-block:: python
|
| 236 |
+
|
| 237 |
+
def test_move_to():
|
| 238 |
+
initial_datetime = datetime.datetime(year=1, month=7, day=12,
|
| 239 |
+
hour=15, minute=6, second=3)
|
| 240 |
+
|
| 241 |
+
other_datetime = datetime.datetime(year=2, month=8, day=13,
|
| 242 |
+
hour=14, minute=5, second=0)
|
| 243 |
+
with freeze_time(initial_datetime) as frozen_datetime:
|
| 244 |
+
assert frozen_datetime() == initial_datetime
|
| 245 |
+
|
| 246 |
+
frozen_datetime.move_to(other_datetime)
|
| 247 |
+
assert frozen_datetime() == other_datetime
|
| 248 |
+
|
| 249 |
+
frozen_datetime.move_to(initial_datetime)
|
| 250 |
+
assert frozen_datetime() == initial_datetime
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
@freeze_time("2012-01-14", as_arg=True)
|
| 254 |
+
def test(frozen_time):
|
| 255 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
|
| 256 |
+
frozen_time.move_to("2014-02-12")
|
| 257 |
+
assert datetime.datetime.now() == datetime.datetime(2014, 2, 12)
|
| 258 |
+
|
| 259 |
+
Parameter for ``move_to`` can be any valid ``freeze_time`` date (string, date, datetime).
|
| 260 |
+
|
| 261 |
+
``real_asyncio`` parameter
|
| 262 |
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| 263 |
+
|
| 264 |
+
FreezeGun has an additional ``real_asyncio`` parameter which allows asyncio event loops to see real monotonic time even though time.monotonic() is frozen. This is useful to avoid breaking asyncio.sleep() and other asyncio functions that rely on monotonic time.
|
| 265 |
+
|
| 266 |
+
.. code-block:: python
|
| 267 |
+
|
| 268 |
+
@freeze_time("2012-01-14", real_asyncio=True)
|
| 269 |
+
async def test_asyncio():
|
| 270 |
+
await asyncio.sleep(1)
|
| 271 |
+
assert datetime.datetime.now() == datetime.datetime(2012, 1, 14)
|
| 272 |
+
|
| 273 |
+
API Documentation
|
| 274 |
+
~~~~~~~~~~~~~~~~~
|
| 275 |
+
|
| 276 |
+
Here is a succinct API documentation with all options listed:
|
| 277 |
+
|
| 278 |
+
.. code-block:: python
|
| 279 |
+
|
| 280 |
+
freeze_time(time_to_freeze: Optional[_Freezable]=None, tz_offset: Union[int, datetime.timedelta]=0, ignore: Optional[List[str]]=None, tick: bool=False, as_arg: bool=False, as_kwarg: str='', auto_tick_seconds: float=0, real_asyncio: bool=False) -> _freeze_time
|
| 281 |
+
|
| 282 |
+
_freeze_time(time_to_freeze_str: Optional[_Freezable], tz_offset: Union[int, datetime.timedelta], ignore: List[str], tick: bool, as_arg: bool, as_kwarg: str, auto_tick_seconds: float, real_asyncio: Optional[bool])
|
| 283 |
+
|
| 284 |
+
_freeze_time.start() -> Union[StepTickTimeFactory, TickingDateTimeFactory, FrozenDateTimeFactory]
|
| 285 |
+
|
| 286 |
+
_freeze_time.stop() -> None
|
| 287 |
+
|
| 288 |
+
_freeze_time.move_to(target_datetime: _Freezable) -> None
|
| 289 |
+
|
| 290 |
+
_freeze_time.tick(delta: Union[datetime.timedelta, float]=datetime.timedelta(seconds=1)) -> datetime.datetime
|
| 291 |
+
|
| 292 |
+
_freeze_time.decorate_class(klass: Type[T2]) -> Type[T2]
|
| 293 |
+
|
| 294 |
+
_freeze_time.decorate_coroutine(coroutine: Callable[P, Awaitable[T]]) -> Callable[P, Awaitable[T]]
|
| 295 |
+
|
| 296 |
+
_freeze_time.decorate_callable(func: Callable[P, T]) -> Callable[P, T]
|
| 297 |
+
|
| 298 |
+
_freeze_time.__enter__() -> Union[StepTickTimeFactory, TickingDateTimeFactory, FrozenDateTimeFactory]
|
| 299 |
+
|
| 300 |
+
_freeze_time.__exit__(*args: Any) -> None
|
| 301 |
+
|
| 302 |
+
Default arguments
|
| 303 |
+
~~~~~~~~~~~~~~~~~
|
| 304 |
+
|
| 305 |
+
Note that FreezeGun will not modify default arguments. The following code will
|
| 306 |
+
print the current date. See `here <http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments>`_ for why.
|
| 307 |
+
|
| 308 |
+
.. code-block:: python
|
| 309 |
+
|
| 310 |
+
from freezegun import freeze_time
|
| 311 |
+
import datetime as dt
|
| 312 |
+
|
| 313 |
+
def test(default=dt.date.today()):
|
| 314 |
+
print(default)
|
| 315 |
+
|
| 316 |
+
with freeze_time('2000-1-1'):
|
| 317 |
+
test()
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
Installation
|
| 321 |
+
------------
|
| 322 |
+
|
| 323 |
+
To install FreezeGun, simply:
|
| 324 |
+
|
| 325 |
+
.. code-block:: bash
|
| 326 |
+
|
| 327 |
+
$ pip install freezegun
|
| 328 |
+
|
| 329 |
+
On Debian systems:
|
| 330 |
+
|
| 331 |
+
.. code-block:: bash
|
| 332 |
+
|
| 333 |
+
$ sudo apt-get install python-freezegun
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
Ignore packages
|
| 337 |
+
---------------
|
| 338 |
+
|
| 339 |
+
Sometimes it's desired to ignore FreezeGun behaviour for particular packages (i.e. libraries).
|
| 340 |
+
It's possible to ignore them for a single invocation:
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
.. code-block:: python
|
| 344 |
+
|
| 345 |
+
from freezegun import freeze_time
|
| 346 |
+
|
| 347 |
+
with freeze_time('2020-10-06', ignore=['threading']):
|
| 348 |
+
# ...
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
By default FreezeGun ignores following packages:
|
| 352 |
+
|
| 353 |
+
.. code-block:: python
|
| 354 |
+
|
| 355 |
+
[
|
| 356 |
+
'nose.plugins',
|
| 357 |
+
'six.moves',
|
| 358 |
+
'django.utils.six.moves',
|
| 359 |
+
'google.gax',
|
| 360 |
+
'threading',
|
| 361 |
+
'Queue',
|
| 362 |
+
'selenium',
|
| 363 |
+
'_pytest.terminal.',
|
| 364 |
+
'_pytest.runner.',
|
| 365 |
+
'gi',
|
| 366 |
+
]
|
| 367 |
+
|
| 368 |
+
|
| 369 |
+
It's possible to set your own default ignore list:
|
| 370 |
+
|
| 371 |
+
.. code-block:: python
|
| 372 |
+
|
| 373 |
+
import freezegun
|
| 374 |
+
|
| 375 |
+
freezegun.configure(default_ignore_list=['threading', 'tensorflow'])
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
Please note this will override default ignore list. If you want to extend existing defaults
|
| 379 |
+
please use:
|
| 380 |
+
|
| 381 |
+
.. code-block:: python
|
| 382 |
+
|
| 383 |
+
import freezegun
|
| 384 |
+
|
| 385 |
+
freezegun.configure(extend_ignore_list=['tensorflow'])
|
.cache/pip/http-v2/3/c/e/7/7/3ce770df07ea321ab056bed31a67391a50e82aea9460d349fd057276
ADDED
|
Binary file (1.2 kB). View file
|
|
|
.cache/pip/http-v2/3/c/e/7/7/3ce770df07ea321ab056bed31a67391a50e82aea9460d349fd057276.body
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: packaging
|
| 3 |
+
Version: 26.0
|
| 4 |
+
Summary: Core utilities for Python packages
|
| 5 |
+
Author-email: Donald Stufft <donald@stufft.io>
|
| 6 |
+
Requires-Python: >=3.8
|
| 7 |
+
Description-Content-Type: text/x-rst
|
| 8 |
+
License-Expression: Apache-2.0 OR BSD-2-Clause
|
| 9 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 10 |
+
Classifier: Intended Audience :: Developers
|
| 11 |
+
Classifier: Programming Language :: Python
|
| 12 |
+
Classifier: Programming Language :: Python :: 3
|
| 13 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 14 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.14
|
| 21 |
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
| 22 |
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
| 23 |
+
Classifier: Typing :: Typed
|
| 24 |
+
License-File: LICENSE
|
| 25 |
+
License-File: LICENSE.APACHE
|
| 26 |
+
License-File: LICENSE.BSD
|
| 27 |
+
Project-URL: Documentation, https://packaging.pypa.io/
|
| 28 |
+
Project-URL: Source, https://github.com/pypa/packaging
|
| 29 |
+
|
| 30 |
+
packaging
|
| 31 |
+
=========
|
| 32 |
+
|
| 33 |
+
.. start-intro
|
| 34 |
+
|
| 35 |
+
Reusable core utilities for various Python Packaging
|
| 36 |
+
`interoperability specifications <https://packaging.python.org/specifications/>`_.
|
| 37 |
+
|
| 38 |
+
This library provides utilities that implement the interoperability
|
| 39 |
+
specifications which have clearly one correct behaviour (eg: :pep:`440`)
|
| 40 |
+
or benefit greatly from having a single shared implementation (eg: :pep:`425`).
|
| 41 |
+
|
| 42 |
+
.. end-intro
|
| 43 |
+
|
| 44 |
+
The ``packaging`` project includes the following: version handling, specifiers,
|
| 45 |
+
markers, requirements, tags, metadata, lockfiles, utilities.
|
| 46 |
+
|
| 47 |
+
Documentation
|
| 48 |
+
-------------
|
| 49 |
+
|
| 50 |
+
The `documentation`_ provides information and the API for the following:
|
| 51 |
+
|
| 52 |
+
- Version Handling
|
| 53 |
+
- Specifiers
|
| 54 |
+
- Markers
|
| 55 |
+
- Requirements
|
| 56 |
+
- Tags
|
| 57 |
+
- Metadata
|
| 58 |
+
- Lockfiles
|
| 59 |
+
- Utilities
|
| 60 |
+
|
| 61 |
+
Installation
|
| 62 |
+
------------
|
| 63 |
+
|
| 64 |
+
Use ``pip`` to install these utilities::
|
| 65 |
+
|
| 66 |
+
pip install packaging
|
| 67 |
+
|
| 68 |
+
The ``packaging`` library uses calendar-based versioning (``YY.N``).
|
| 69 |
+
|
| 70 |
+
Discussion
|
| 71 |
+
----------
|
| 72 |
+
|
| 73 |
+
If you run into bugs, you can file them in our `issue tracker`_.
|
| 74 |
+
|
| 75 |
+
You can also join ``#pypa`` on Freenode to ask questions or get involved.
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
.. _`documentation`: https://packaging.pypa.io/
|
| 79 |
+
.. _`issue tracker`: https://github.com/pypa/packaging/issues
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
Code of Conduct
|
| 83 |
+
---------------
|
| 84 |
+
|
| 85 |
+
Everyone interacting in the packaging project's codebases, issue trackers, chat
|
| 86 |
+
rooms, and mailing lists is expected to follow the `PSF Code of Conduct`_.
|
| 87 |
+
|
| 88 |
+
.. _PSF Code of Conduct: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
|
| 89 |
+
|
| 90 |
+
Contributing
|
| 91 |
+
------------
|
| 92 |
+
|
| 93 |
+
The ``CONTRIBUTING.rst`` file outlines how to contribute to this project as
|
| 94 |
+
well as how to report a potential security issue. The documentation for this
|
| 95 |
+
project also covers information about `project development`_ and `security`_.
|
| 96 |
+
|
| 97 |
+
.. _`project development`: https://packaging.pypa.io/en/latest/development/
|
| 98 |
+
.. _`security`: https://packaging.pypa.io/en/latest/security/
|
| 99 |
+
|
| 100 |
+
Project History
|
| 101 |
+
---------------
|
| 102 |
+
|
| 103 |
+
Please review the ``CHANGELOG.rst`` file or the `Changelog documentation`_ for
|
| 104 |
+
recent changes and project history.
|
| 105 |
+
|
| 106 |
+
.. _`Changelog documentation`: https://packaging.pypa.io/en/latest/changelog/
|
| 107 |
+
|
.cache/pip/http-v2/3/d/0/1/0/3d010bbe832a78f7d62973a62c254ff82b3b6531c47ffeeeb5a7dd5e
ADDED
|
Binary file (1.79 kB). View file
|
|
|
.cache/pip/http-v2/3/d/0/1/0/3d010bbe832a78f7d62973a62c254ff82b3b6531c47ffeeeb5a7dd5e.body
ADDED
|
Binary file (6.3 kB). View file
|
|
|