Skip to content

Commit 892221b

Browse files
adamchainzbrettcannon
authored andcommitted
bpo-38839: Fix some unused functions in tests (GH-17189)
1 parent 54b32c9 commit 892221b

File tree

9 files changed

+12
-19
lines changed

9 files changed

+12
-19
lines changed

Lib/distutils/tests/support.py

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def _log(self, level, msg, args):
3939
self.logs.append((level, msg, args))
4040

4141
def get_logs(self, *levels):
42-
def _format(msg, args):
43-
return msg % args
4442
return [msg % args for level, msg, args
4543
in self.logs if level in levels]
4644

Lib/test/test_asynchat.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ def __init__(self, terminator, server_port):
7373
self.set_terminator(terminator)
7474
self.buffer = b""
7575

76-
def handle_connect(self):
77-
pass
76+
def handle_connect(self):
77+
pass
7878

79-
if sys.platform == 'darwin':
80-
# select.poll returns a select.POLLHUP at the end of the tests
81-
# on darwin, so just ignore it
82-
def handle_expt(self):
83-
pass
79+
if sys.platform == 'darwin':
80+
# select.poll returns a select.POLLHUP at the end of the tests
81+
# on darwin, so just ignore it
82+
def handle_expt(self):
83+
pass
8484

8585
def collect_incoming_data(self, data):
8686
self.buffer += data

Lib/test/test_buffer.py

-2
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,6 @@ def check_memoryview(m, expected_readonly=readonly):
969969
m.tobytes() # Releasing mm didn't release m
970970

971971
def verify_getbuf(self, orig_ex, ex, req, sliced=False):
972-
def simple_fmt(ex):
973-
return ex.format == '' or ex.format == 'B'
974972
def match(req, flag):
975973
return ((req&flag) == flag)
976974

Lib/test/test_builtin.py

+1
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ def test_hash(self):
765765
self.assertEqual(hash('spam'), hash(b'spam'))
766766
hash((0,1,2,3))
767767
def f(): pass
768+
hash(f)
768769
self.assertRaises(TypeError, hash, [])
769770
self.assertRaises(TypeError, hash, {})
770771
# Bug 1536021: Allow hash to return long objects

Lib/test/test_code.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def func():
241241
def func2():
242242
y = 2
243243
return y
244-
code2 = func.__code__
244+
code2 = func2.__code__
245245

246246
for attr, value in (
247247
("co_argcount", 0),

Lib/test/test_importlib/import_/test_relative_imports.py

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def callback(global_):
133133
self.assertEqual(module.__name__, 'pkg')
134134
self.assertTrue(hasattr(module, 'subpkg2'))
135135
self.assertEqual(module.subpkg2.attr, 'pkg.subpkg2.__init__')
136+
self.relative_import_test(create, globals_, callback)
136137

137138
def test_deep_import(self):
138139
# [deep import]

Lib/unittest/test/testmock/testasync.py

+1
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ def test_is_AsyncMock_patch(self):
335335
@patch.object(AsyncClass, 'async_method', spec_set=True)
336336
def test_async(async_method):
337337
self.assertIsInstance(async_method, AsyncMock)
338+
test_async()
338339

339340
def test_is_async_AsyncMock(self):
340341
mock = AsyncMock(spec_set=AsyncClass.async_method)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix some unused functions in tests. Patch by Adam Johnson.

Tools/ccbench/ccbench.py

-7
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ def task_regex():
8484
pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)', re.MULTILINE)
8585
with open(__file__, "r") as f:
8686
arg = f.read(2000)
87-
88-
def findall(s):
89-
t = time.time()
90-
try:
91-
return pat.findall(s)
92-
finally:
93-
print(time.time() - t)
9487
return pat.findall, (arg, )
9588

9689
def task_sort():

0 commit comments

Comments
 (0)