bpo-45668: Fix PGO tests without test extensions (GH-29315)

This commit is contained in:
Christian Heimes 2021-11-01 12:14:53 +02:00 committed by GitHub
parent 762a4dc936
commit e73283a20f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 60 additions and 28 deletions

View file

@ -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):