Created
March 7, 2019 09:54
-
-
Save szobov/f670259ee6b0de7db1cf86ad65c678ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.fixture | |
def mock_utcnow(monkeypatch): | |
def wrapped(now=datetime.min): | |
monkeypatch.setattr(utils, "get_utcnow", lambda: now) | |
return wrapped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
def test(mock_utcnow): | |
fake_now = datetime.utcnow() | |
mock_utcnow(fake_now) | |
another_fake_now = datetime.utcnow() | |
mock_utcnow(fake_now) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment