Skip to content

Commit 71436ad

Browse files
authored
Merge pull request #320 from musicinmybrain/unittest-mock
Drop PyPI mock package dependency on Python 3.3+
2 parents b8e5942 + 605e5d5 commit 71436ad

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

tests/ext/aiohttp/test_middleware.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
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+
# NOTE: Python 2 dependency
12+
from mock import patch
913

1014
from aiohttp import web
1115
from aiohttp.web_exceptions import HTTPUnauthorized

tests/ext/django/test_settings.py

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

37
import django
48
from aws_xray_sdk import global_sdk_config
@@ -13,4 +17,4 @@
1317
class XRayConfigurationTestCase(TestCase):
1418
def test_sampler_can_be_configured(self):
1519
assert isinstance(settings.XRAY_RECORDER['SAMPLER'], LocalSampler)
16-
assert isinstance(xray_recorder.sampler, LocalSampler)
20+
assert isinstance(xray_recorder.sampler, LocalSampler)

tests/test_plugins.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
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+
# NOTE: Python 2 dependency
6+
from mock import patch
37

48
supported_plugins = (
59
'ec2_plugin',

tox.ini

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ deps =
3636
testing.postgresql
3737
testing.mysqld
3838
webtest
39-
mock
40-
4139
# Python2 only deps
42-
py{27}: enum34
40+
py{27}: enum34 mock
4341

4442
# pymysql deps
4543
py{27,34,35}: pymysql < 1.0.0

0 commit comments

Comments
 (0)