bpo-38839: Fix some unused functions in tests (GH-17189)
This commit is contained in:
parent
54b32c9871
commit
892221bfa0
|
@ -39,8 +39,6 @@ class LoggingSilencer(object):
|
||||||
self.logs.append((level, msg, args))
|
self.logs.append((level, msg, args))
|
||||||
|
|
||||||
def get_logs(self, *levels):
|
def get_logs(self, *levels):
|
||||||
def _format(msg, args):
|
|
||||||
return msg % args
|
|
||||||
return [msg % args for level, msg, args
|
return [msg % args for level, msg, args
|
||||||
in self.logs if level in levels]
|
in self.logs if level in levels]
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,14 @@ class echo_client(asynchat.async_chat):
|
||||||
self.set_terminator(terminator)
|
self.set_terminator(terminator)
|
||||||
self.buffer = b""
|
self.buffer = b""
|
||||||
|
|
||||||
def handle_connect(self):
|
def handle_connect(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
# select.poll returns a select.POLLHUP at the end of the tests
|
# select.poll returns a select.POLLHUP at the end of the tests
|
||||||
# on darwin, so just ignore it
|
# on darwin, so just ignore it
|
||||||
def handle_expt(self):
|
def handle_expt(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def collect_incoming_data(self, data):
|
def collect_incoming_data(self, data):
|
||||||
self.buffer += data
|
self.buffer += data
|
||||||
|
|
|
@ -969,8 +969,6 @@ class TestBufferProtocol(unittest.TestCase):
|
||||||
m.tobytes() # Releasing mm didn't release m
|
m.tobytes() # Releasing mm didn't release m
|
||||||
|
|
||||||
def verify_getbuf(self, orig_ex, ex, req, sliced=False):
|
def verify_getbuf(self, orig_ex, ex, req, sliced=False):
|
||||||
def simple_fmt(ex):
|
|
||||||
return ex.format == '' or ex.format == 'B'
|
|
||||||
def match(req, flag):
|
def match(req, flag):
|
||||||
return ((req&flag) == flag)
|
return ((req&flag) == flag)
|
||||||
|
|
||||||
|
|
|
@ -765,6 +765,7 @@ class BuiltinTest(unittest.TestCase):
|
||||||
self.assertEqual(hash('spam'), hash(b'spam'))
|
self.assertEqual(hash('spam'), hash(b'spam'))
|
||||||
hash((0,1,2,3))
|
hash((0,1,2,3))
|
||||||
def f(): pass
|
def f(): pass
|
||||||
|
hash(f)
|
||||||
self.assertRaises(TypeError, hash, [])
|
self.assertRaises(TypeError, hash, [])
|
||||||
self.assertRaises(TypeError, hash, {})
|
self.assertRaises(TypeError, hash, {})
|
||||||
# Bug 1536021: Allow hash to return long objects
|
# Bug 1536021: Allow hash to return long objects
|
||||||
|
|
|
@ -241,7 +241,7 @@ class CodeTest(unittest.TestCase):
|
||||||
def func2():
|
def func2():
|
||||||
y = 2
|
y = 2
|
||||||
return y
|
return y
|
||||||
code2 = func.__code__
|
code2 = func2.__code__
|
||||||
|
|
||||||
for attr, value in (
|
for attr, value in (
|
||||||
("co_argcount", 0),
|
("co_argcount", 0),
|
||||||
|
|
|
@ -133,6 +133,7 @@ class RelativeImports:
|
||||||
self.assertEqual(module.__name__, 'pkg')
|
self.assertEqual(module.__name__, 'pkg')
|
||||||
self.assertTrue(hasattr(module, 'subpkg2'))
|
self.assertTrue(hasattr(module, 'subpkg2'))
|
||||||
self.assertEqual(module.subpkg2.attr, 'pkg.subpkg2.__init__')
|
self.assertEqual(module.subpkg2.attr, 'pkg.subpkg2.__init__')
|
||||||
|
self.relative_import_test(create, globals_, callback)
|
||||||
|
|
||||||
def test_deep_import(self):
|
def test_deep_import(self):
|
||||||
# [deep import]
|
# [deep import]
|
||||||
|
|
|
@ -335,6 +335,7 @@ class AsyncSpecSetTest(unittest.TestCase):
|
||||||
@patch.object(AsyncClass, 'async_method', spec_set=True)
|
@patch.object(AsyncClass, 'async_method', spec_set=True)
|
||||||
def test_async(async_method):
|
def test_async(async_method):
|
||||||
self.assertIsInstance(async_method, AsyncMock)
|
self.assertIsInstance(async_method, AsyncMock)
|
||||||
|
test_async()
|
||||||
|
|
||||||
def test_is_async_AsyncMock(self):
|
def test_is_async_AsyncMock(self):
|
||||||
mock = AsyncMock(spec_set=AsyncClass.async_method)
|
mock = AsyncMock(spec_set=AsyncClass.async_method)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix some unused functions in tests. Patch by Adam Johnson.
|
|
@ -84,13 +84,6 @@ def task_regex():
|
||||||
pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)', re.MULTILINE)
|
pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)', re.MULTILINE)
|
||||||
with open(__file__, "r") as f:
|
with open(__file__, "r") as f:
|
||||||
arg = f.read(2000)
|
arg = f.read(2000)
|
||||||
|
|
||||||
def findall(s):
|
|
||||||
t = time.time()
|
|
||||||
try:
|
|
||||||
return pat.findall(s)
|
|
||||||
finally:
|
|
||||||
print(time.time() - t)
|
|
||||||
return pat.findall, (arg, )
|
return pat.findall, (arg, )
|
||||||
|
|
||||||
def task_sort():
|
def task_sort():
|
||||||
|
|
Loading…
Reference in New Issue