Skip to content

Commit bbc4c70

Browse files
Merge pull request OpenKMIP#239 from OpenKMIP/bug/fix-server-mock-open
Fixes how open is mocked in the server test suite
2 parents 6374f91 + 239ec71 commit bbc4c70

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

kmip/tests/unit/services/server/test_server.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515

1616
import errno
1717
import logging
18-
import mock
18+
19+
try:
20+
import unittest.mock as mock
21+
except:
22+
import mock
23+
1924
import signal
2025
import socket
2126
import testtools
@@ -75,9 +80,11 @@ def test_setup_logging(
7580
# Dynamically mock out the built-in open function. Approach changes
7681
# across Python versions.
7782
try:
78-
import io # NOQA
79-
module = 'kmip.services.server.server'
80-
except:
83+
# For Python3+
84+
import builtins # NOQA
85+
module = 'builtins'
86+
except ImportError:
87+
# For Python2+
8188
module = '__builtin__'
8289

8390
with mock.patch('{0}.open'.format(module), open_mock):

0 commit comments

Comments
 (0)