Skip to content

Commit 99577ee

Browse files
committed
prefer unittest.mock from the standard library for Python >=3.8
1 parent 3863205 commit 99577ee

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

tests/unit/http/test_async_http_client.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import aiounittest
22

33
from aiohttp import ClientSession
4-
from mock import patch, AsyncMock
4+
try:
5+
from unittest.mock import patch, AsyncMock
6+
except ImportError:
7+
# Python 3.7
8+
from mock import patch, AsyncMock
59
from twilio.http.async_http_client import AsyncTwilioHttpClient
610

711

tests/unit/http/test_http_client.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import unittest
44
from collections import OrderedDict
55

6-
from mock import Mock, patch
6+
try:
7+
from unittest.mock import Mock, patch
8+
except ImportError:
9+
# Python 3.7
10+
from mock import Mock, patch
711
from requests import Session
812

913
from twilio.base.exceptions import TwilioRestException

tests/unit/http/test_validation_client.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import unittest
44

5-
from mock import patch, Mock
5+
try:
6+
from unittest.mock import patch, Mock
7+
except ImportError:
8+
# Python 3.7
9+
from mock import patch, Mock
610
from requests import Request
711
from requests import Session
812

tests/unit/jwt/test_jwt.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
import unittest
33

44
import jwt as jwt_lib
5-
from mock import patch
5+
try:
6+
from unittest.mock import patch
7+
except ImportError:
8+
# Python 3.7
9+
from mock import patch
610

711
from twilio.jwt import Jwt, JwtDecodeError
812

tests/unit/rest/test_client.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import unittest
22
import aiounittest
33

4-
from mock import AsyncMock, Mock
4+
try:
5+
from unittest.mock import AsyncMock, Mock
6+
except ImportError:
7+
# Python 3.7
8+
from mock import AsyncMock, Mock
59
from twilio.http.response import Response
610
from twilio.rest import Client
711

0 commit comments

Comments
 (0)