Skip to content

Commit

Permalink
Work around an obscure issue with @freeze_time() on Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
gsakkis committed Feb 13, 2017
1 parent 91c6d2f commit 37e1ee0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,13 @@ def test_local_task_job(self):
job = jobs.LocalTaskJob(task_instance=ti, ignore_ti_state=True)
job.run()

@freeze_time('2016-01-01')
# XXX: For some obscure reason, @freeze_time() causes test_scheduler_job to
# hang on Python 3 using LocalExecutor. So work around it by mocking and
# patching just the necessary datetime.now instances
mock_datetime = mock.Mock(side_effect=datetime,
now=mock.Mock(return_value=datetime(2016, 1, 1)))
@mock.patch('airflow.jobs.datetime', mock_datetime)
@mock.patch('airflow.utils.dag_processing.datetime', mock_datetime)
def test_scheduler_job(self):
job = jobs.SchedulerJob(dag_id='example_bash_operator',
**self.default_scheduler_args)
Expand Down

0 comments on commit 37e1ee0

Please sign in to comment.