Skip to content

Commit 263a198

Browse files
Drop PyPI mock package dep. on Python 3.3+
Use unittest.mock from the standard library where available.
1 parent b8e5942 commit 263a198

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

tests/ext/aiohttp/test_middleware.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"""
66
import asyncio
77
from aws_xray_sdk import global_sdk_config
8-
from unittest.mock import patch
8+
try:
9+
from unittest.mock import patch
10+
except ImportError:
11+
from mock import patch # Python 2
912

1013
from aiohttp import web
1114
from aiohttp.web_exceptions import HTTPUnauthorized

tests/ext/django/test_settings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from unittest import mock
1+
try:
2+
from unittest import mock
3+
except ImportError:
4+
import mock # Python 2
25

36
import django
47
from aws_xray_sdk import global_sdk_config
@@ -13,4 +16,4 @@
1316
class XRayConfigurationTestCase(TestCase):
1417
def test_sampler_can_be_configured(self):
1518
assert isinstance(settings.XRAY_RECORDER['SAMPLER'], LocalSampler)
16-
assert isinstance(xray_recorder.sampler, LocalSampler)
19+
assert isinstance(xray_recorder.sampler, LocalSampler)

tests/test_plugins.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from aws_xray_sdk.core.plugins.utils import get_plugin_modules
2-
from mock import patch
2+
try:
3+
from unittest.mock import patch
4+
except ImportError:
5+
from mock import patch # Python 2
36

47
supported_plugins = (
58
'ec2_plugin',

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ deps =
3636
testing.postgresql
3737
testing.mysqld
3838
webtest
39-
mock
39+
mock ; python_version < '3.3'
4040

4141
# Python2 only deps
4242
py{27}: enum34

0 commit comments

Comments
 (0)