]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38839: Fix some unused functions in tests (GH-17189)
authorAdam Johnson <me@adamj.eu>
Tue, 19 Nov 2019 19:45:20 +0000 (19:45 +0000)
committerBrett Cannon <54418+brettcannon@users.noreply.github.com>
Tue, 19 Nov 2019 19:45:20 +0000 (11:45 -0800)
Lib/distutils/tests/support.py
Lib/test/test_asynchat.py
Lib/test/test_buffer.py
Lib/test/test_builtin.py
Lib/test/test_code.py
Lib/test/test_importlib/import_/test_relative_imports.py
Lib/unittest/test/testmock/testasync.py
Misc/NEWS.d/next/Tests/2019-11-18-22-10-55.bpo-38839.di6tXv.rst [new file with mode: 0644]
Tools/ccbench/ccbench.py

index 041309851d0f39e6da461a5a4a55c51f785dd050..259af882ec0e968afc12b8e347ad82b28617aa1a 100644 (file)
@@ -39,8 +39,6 @@ class LoggingSilencer(object):
         self.logs.append((level, msg, args))
 
     def get_logs(self, *levels):
-        def _format(msg, args):
-            return msg % args
         return [msg % args for level, msg, args
                 in self.logs if level in levels]
 
index 14c0ec43d422ea5e4c3cedec79ccfb7f63d01344..74041ed58ef702f3feaf916c3e3e85c9d0b8248c 100644 (file)
@@ -73,14 +73,14 @@ class echo_client(asynchat.async_chat):
         self.set_terminator(terminator)
         self.buffer = b""
 
-        def handle_connect(self):
-            pass
+    def handle_connect(self):
+        pass
 
-        if sys.platform == 'darwin':
-            # select.poll returns a select.POLLHUP at the end of the tests
-            # on darwin, so just ignore it
-            def handle_expt(self):
-                pass
+    if sys.platform == 'darwin':
+        # select.poll returns a select.POLLHUP at the end of the tests
+        # on darwin, so just ignore it
+        def handle_expt(self):
+            pass
 
     def collect_incoming_data(self, data):
         self.buffer += data
index 5fa52bffc22be70d42c6d013b7030a73ae557c1a..0aa78016f5d1acdf66911e497171f4093df7392a 100644 (file)
@@ -969,8 +969,6 @@ class TestBufferProtocol(unittest.TestCase):
             m.tobytes()  # Releasing mm didn't release m
 
     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):
             return ((req&flag) == flag)
 
index abccf32227444818dce4dedd19366127bfc49cb7..6a88454289d3472331d8beb1e0df57cf577c4010 100644 (file)
@@ -765,6 +765,7 @@ class BuiltinTest(unittest.TestCase):
         self.assertEqual(hash('spam'), hash(b'spam'))
         hash((0,1,2,3))
         def f(): pass
+        hash(f)
         self.assertRaises(TypeError, hash, [])
         self.assertRaises(TypeError, hash, {})
         # Bug 1536021: Allow hash to return long objects
index 0d80af44d9f1ffb6b8af1bed54b1c797b4ca919d..656c46cfaa757acd577781dd96d4fe20fff4e3f7 100644 (file)
@@ -241,7 +241,7 @@ class CodeTest(unittest.TestCase):
         def func2():
             y = 2
             return y
-        code2 = func.__code__
+        code2 = func2.__code__
 
         for attr, value in (
             ("co_argcount", 0),
index 586a9bf4bc1215ba651300185a9fea78a66663c5..41aa18269952fae958f4f498783dee996a1ad3b0 100644 (file)
@@ -133,6 +133,7 @@ class RelativeImports:
             self.assertEqual(module.__name__, 'pkg')
             self.assertTrue(hasattr(module, 'subpkg2'))
             self.assertEqual(module.subpkg2.attr, 'pkg.subpkg2.__init__')
+        self.relative_import_test(create, globals_, callback)
 
     def test_deep_import(self):
         # [deep import]
index 6b2d49d3e44d27ac8f274380b1d3376d36c913f0..0d2cdb0069ff7d04871add946edae7ad1b8f8d6b 100644 (file)
@@ -335,6 +335,7 @@ class AsyncSpecSetTest(unittest.TestCase):
         @patch.object(AsyncClass, 'async_method', spec_set=True)
         def test_async(async_method):
             self.assertIsInstance(async_method, AsyncMock)
+        test_async()
 
     def test_is_async_AsyncMock(self):
         mock = AsyncMock(spec_set=AsyncClass.async_method)
diff --git a/Misc/NEWS.d/next/Tests/2019-11-18-22-10-55.bpo-38839.di6tXv.rst b/Misc/NEWS.d/next/Tests/2019-11-18-22-10-55.bpo-38839.di6tXv.rst
new file mode 100644 (file)
index 0000000..80c5a5b
--- /dev/null
@@ -0,0 +1 @@
+Fix some unused functions in tests. Patch by Adam Johnson.
index 4f77a65f4d779ba34f659c2c87a7c6345aad01da..ab1465a276092310cd85654aa51b1c1298c52f36 100644 (file)
@@ -84,13 +84,6 @@ def task_regex():
     pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)', re.MULTILINE)
     with open(__file__, "r") as f:
         arg = f.read(2000)
-
-    def findall(s):
-        t = time.time()
-        try:
-            return pat.findall(s)
-        finally:
-            print(time.time() - t)
     return pat.findall, (arg, )
 
 def task_sort():