summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 49decac..94873ff 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -7,6 +7,7 @@ import struct
import sys
from test import support
+from test.support import import_helper
from test.support.script_helper import assert_python_ok
ISBIGENDIAN = sys.byteorder == "big"
@@ -680,8 +681,8 @@ class StructTest(unittest.TestCase):
@support.cpython_only
def test_issue45034_unsigned(self):
- from _testcapi import USHRT_MAX
- error_msg = f'ushort format requires 0 <= number <= {USHRT_MAX}'
+ _testcapi = import_helper.import_module('_testcapi')
+ error_msg = f'ushort format requires 0 <= number <= {_testcapi.USHRT_MAX}'
with self.assertRaisesRegex(struct.error, error_msg):
struct.pack('H', 70000) # too large
with self.assertRaisesRegex(struct.error, error_msg):
@@ -689,8 +690,8 @@ class StructTest(unittest.TestCase):
@support.cpython_only
def test_issue45034_signed(self):
- from _testcapi import SHRT_MIN, SHRT_MAX
- error_msg = f'short format requires {SHRT_MIN} <= number <= {SHRT_MAX}'
+ _testcapi = import_helper.import_module('_testcapi')
+ error_msg = f'short format requires {_testcapi.SHRT_MIN} <= number <= {_testcapi.SHRT_MAX}'
with self.assertRaisesRegex(struct.error, error_msg):
struct.pack('h', 70000) # too large
with self.assertRaisesRegex(struct.error, error_msg):