request_test_lib.py: Move from mock to unittest.mock.
This commit changes 'Mock.assert_called()' to 'assert Mock.called'. This is needed because in unittest.mock, assert_called() is only supported in Python >=3.6.
This commit is contained in:
parent
b46a079804
commit
e48a958780
|
@ -2,7 +2,7 @@ import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ def mock_request_exception():
|
||||||
# type: () -> Any
|
# type: () -> Any
|
||||||
def assert_mock_called(mock_result):
|
def assert_mock_called(mock_result):
|
||||||
# type: (Any) -> None
|
# type: (Any) -> None
|
||||||
mock_result.assert_called()
|
assert mock_result.called
|
||||||
|
|
||||||
with patch('requests.get') as mock_get:
|
with patch('requests.get') as mock_get:
|
||||||
mock_get.return_value = True
|
mock_get.return_value = True
|
||||||
|
|
Loading…
Reference in a new issue