def test_parse_deadline(spec, expected_deadline): """``unit=num`` specs can be translated into ``datetime`` instances.""" # Note: Can't mock ``utcnow`` directly because ``datetime`` is a built-in. class MockDatetime(datetime): @staticmethod def utcnow(): return dt('2017-07-07T10:00:00.000Z') with mock.patch('datetime.datetime', MockDatetime): assert parse_deadline(spec) == expected_deadline