Skip to content

Commit 451de14

Browse files
committed
quiet bytes warning in test
1 parent c8be70d commit 451de14

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎Lib/test/seq_tests.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pickle
99
from test import support
1010
from test.support import ALWAYS_EQ, NEVER_EQ
11+
from test.support import warnings_helper
1112

1213
# Various iterables
1314
# This is used for checking the constructor (here and in test_deque.py)
@@ -465,6 +466,8 @@ def make_haystacks(self, fmt, raw):
465466
"""
466467
raise NotImplementedError
467468

469+
# Comparing bytes needles with int items emits BytesWarning with -b.
470+
@warnings_helper.ignore_warnings(category=BytesWarning)
468471
def run_search_cases(self, check):
469472
"""Call check(haystack, haystack_objects, needle) for every needle
470473
of every haystack, with a subtest for each haystack.

‎Lib/test/test_array.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import unittest
77
from test import support
88
from test.seq_tests import NativeItemsSearchTest
9-
from test.support import import_helper, script_helper
9+
from test.support import import_helper, script_helper, warnings_helper
1010
from test.support import os_helper
1111
from test.support import _2G
1212
from test.support import subTests
@@ -209,6 +209,8 @@ def check_remove(self, a, haystack_objects, needle):
209209
with self.assertRaises(ValueError, msg=repr(needle)):
210210
b.remove(needle)
211211

212+
# Comparing bytes needles with str items emits BytesWarning with -b.
213+
@warnings_helper.ignore_warnings(category=BytesWarning)
212214
def test_search_unicode(self):
213215
a = array.array('w', 'abc\U0010ffff\0ab' * 2)
214216
haystack_objects = a.tolist()

0 commit comments

Comments
 (0)