ashb commented on a change in pull request #6311:
URL: https://github.com/apache/airflow/pull/6311#discussion_r427934971
##########
File path: tests/conftest.py
##########
@@ -415,3 +417,39 @@ def pytest_runtest_setup(item):
skip_quarantined_test(item)
skip_if_credential_file_missing(item)
skip_if_airflow_2_test(item)
+
+
[email protected]
+def frozen_sleep(monkeypatch):
+ """
+ Use freezegun to "stub" sleep, so that it takes no time, but that
+ ``datetime.now()`` appears to move forwards
+
+ If your module under test does ``import time`` and then ``time.sleep``::
+
+ def test_something(frozen_sleep):
+ my_mod.fn_under_test()
+
+
+ If your module under test does ``from time import sleep`` then you will
+ have to mock that sleep function directly::
+
+ def test_something(frozen_sleep, monkeypatch):
+ monkeypatch.setattr('my_mod.sleep', frozen_sleep)
+ my_mod.fn_under_test()
+ """
+ freezegun_control = None
+
+ def fake_sleep(seconds):
+ nonlocal freezegun_control
Review comment:
Given this is tests only I don't mind that much.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]