コード例 #1
0
def test_get_holidays_timeout(mock_requests):
    mock_requests.get.side_effect = Timeout

    with pytest.raises(Timeout):
        get_holidays()

    mock_requests.get.assert_called_once()
コード例 #2
0
def test_get_holidays_timeout():
    with patch('patch_example.my_calendar.requests') as mock_requests:
        mock_requests.get.side_effect = Timeout
        with pytest.raises(Timeout):
            get_holidays()

        mock_requests.get.assert_called_once()
コード例 #3
0
def test_get_holidays_timeout(mock_placeholder):

    with pytest.raises(requests.exceptions.Timeout):
        get_holidays()

    # Keep on working as expected
    r = requests.post("https://jsonplaceholder.typicode.com/posts")
    print(r.json())
コード例 #4
0
def test_get_holidays_timeout(mock_requests):
    mock_requests.get.side_effect = Timeout

    with pytest.raises(Timeout):
        get_holidays()

    # Keep on working as expected
    r = requests.get("https://jsonplaceholder.typicode.com/posts")
    print(r.json())
コード例 #5
0
def test_get_holidays_timeout():

    with patch('patch_example.my_calendar.requests') as mock_requests:
        mock_requests.get.side_effect = Timeout

        with pytest.raises(Timeout):
            get_holidays()

        mock_requests.get.assert_called_once()

    r = requests.post("https://jsonplaceholder.typicode.com/posts")
    print(r.json())