在冻结时间内用夹具包装测试

pytest-freezegun的Python项目详细描述


=====
pytest冷冻枪
=====


图片::https://travis-ci.org/ktosiek/pytest-freezegun.svg?branch=master
:目标:https://travis ci.org/ktosiek/pytest freezegun
:alt:请参阅travis ci上的构建状态

…图片::https://ci.appveyor.com/api/projects/status/github/ktosiek/pytest-freezegun?分支=主&;svg=true
:target:https://ci.appveyor.com/project/ktosiek/pytest-freezegun/branch/master
:alt:see build status on appveyor

它的安装


代码块::python

@pytest.fixture
def current戥date():
return date time.now().date()

@pytest.mark.freeze戥time('2017-05-21')
def test戥current戥date(current戥date):
assert current戥date==date(2017,5,21)

@pytest.mark.freeze_time
def test_changing_date(current_date,冰柜):
freezer.move_to('2017-05-20')
assert current_date==date(2017,5,20)
freezer.move_to('2017-05-21')
assert current_date==date(2017,5,21)

def test_not_using_marker(freezer):
now=datetime.now()
time.sleep(1)
later=datetime.now()
assert now==later

contribution
----
贡献非常受欢迎。
可以使用“tox”运行测试。
以后可以使用“coverage combine&;&;coverage html`.
在提交请求之前,请尽量保持覆盖率至少相同。

详细说明。

credits
----


_` Cookiecutter`:https://github.com/audreyr/Cookiecutter
。_`@hackebrot`:https://github.com/hackebrot
。_` mit`:http://opensource.org/licenses/mit
。_` cookiecutter pytest plugin`:https://github.com/pytest dev/cookiecutter pytest plugin
。_`提交问题:https://github.com/ktosiek/pytest freezegun/issues
。_` pytest`:https://github.com/pytest dev/pytest
。_` tox`:https://tox.readthedocs.io/en/latest/
。_` pip`:https://pypi.python.org/pypi/pip/
。_` pypi`:https://pypi.python.org/pypi



欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何表示1。。Java中的n关系   java在安卓应用程序中添加polaris viewer   Java字符串::replaceAll仅替换第一个出现(可能不正确的正则表达式)   java Tomcat/JBoss部署后脚本   如何在Heroku Java应用程序中运行发出web请求的周期进程   java如何以纳秒为单位证明算法的时间   Solaris上的java自定义ListCellRenderer(使用jre5)   java试图为我的播放器类测试块实现播放器重力(RealtutsGml平台教程)   c#消耗一个。带有java的net web服务未显示预期结果   java在KOI8\R中检索html   基于java图形的搜索与基于随机的搜索   java如何检查安卓设备上的可用空间?在SD卡上?