summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-11-01 10:14:53 (GMT)
committerGitHub <noreply@github.com>2021-11-01 10:14:53 (GMT)
commite73283a20fb05b70da2990decefac0e011faec17 (patch)
treea490f99e1eab3e779b5828b8f51994e91b4aa2b6 /Lib/test/test_struct.py
parent762a4dc9361f9563e158e373ba8d767b4449f23d (diff)
downloadcpython-e73283a20fb05b70da2990decefac0e011faec17.zip
cpython-e73283a20fb05b70da2990decefac0e011faec17.tar.gz
cpython-e73283a20fb05b70da2990decefac0e011faec17.tar.bz2
bpo-45668: Fix PGO tests without test extensions (GH-29315)
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):