[Python-checkins] [3.10] bpo-46198: rename duplicate tests and remove unused code (GH-30297) (GH-31796)

JelleZijlstra webhook-mailer at python.org
Thu Mar 10 16:53:59 EST 2022


https://github.com/python/cpython/commit/4199b7ffbbaa5fe52a4c85c8672ac6773a75ba8f
commit: 4199b7ffbbaa5fe52a4c85c8672ac6773a75ba8f
branch: 3.10
author: Jelle Zijlstra <jelle.zijlstra at gmail.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-03-10T13:53:50-08:00
summary:

[3.10] bpo-46198: rename duplicate tests and remove unused code (GH-30297) (GH-31796)

(cherry picked from commit 6c83c8e6b56b57a8a794e7b6c07837be4ce3bb97)

Co-authored-by: Nikita Sobolev <mail at sobolevn.me>

files:
M Lib/test/datetimetester.py
M Lib/test/support/__init__.py
M Lib/test/test_asyncio/test_sslproto.py
M Lib/test/test_codecs.py
M Lib/test/test_compile.py
M Lib/test/test_dict.py
M Lib/test/test_email/test__header_value_parser.py
M Lib/test/test_pty.py
M Lib/test/test_tabnanny.py

diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 9f551d9b9748d..58336595c1f57 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -1861,8 +1861,6 @@ def test_fromisoformat_fails(self):
 
     def test_fromisoformat_fails_typeerror(self):
         # Test that fromisoformat fails when passed the wrong type
-        import io
-
         bad_types = [b'2009-03-01', None, io.StringIO('2009-03-01')]
         for bad_type in bad_types:
             with self.assertRaises(TypeError):
@@ -3985,8 +3983,6 @@ def test_fromisoformat_fails(self):
 
     def test_fromisoformat_fails_typeerror(self):
         # Test the fromisoformat fails when passed the wrong type
-        import io
-
         bad_types = [b'12:30:45', None, io.StringIO('12:30:45')]
 
         for bad_type in bad_types:
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index ed6f1979732d3..63435780c9a58 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1381,9 +1381,6 @@ def __init__(self, link=None):
 
         self._platform_specific()
 
-    def _platform_specific(self):
-        pass
-
     if sys.platform == "win32":
         def _platform_specific(self):
             import glob
@@ -1411,6 +1408,9 @@ def _platform_specific(self):
             self._env["PYTHONHOME"] = os.path.dirname(self.real)
             if sysconfig.is_python_build(True):
                 self._env["PYTHONPATH"] = os.path.dirname(os.__file__)
+    else:
+        def _platform_specific(self):
+            pass
 
     def __enter__(self):
         os.symlink(self.real, self.link)
diff --git a/Lib/test/test_asyncio/test_sslproto.py b/Lib/test/test_asyncio/test_sslproto.py
index 22a216a83e3f9..f7411a8142cc8 100644
--- a/Lib/test/test_asyncio/test_sslproto.py
+++ b/Lib/test/test_asyncio/test_sslproto.py
@@ -2,7 +2,6 @@
 
 import logging
 import socket
-from test import support
 import unittest
 import weakref
 from unittest import mock
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index f7310fbb1474a..a9c43d9554bea 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -32,7 +32,7 @@ def check(input, expect):
 # On small versions of Windows like Windows IoT or Windows Nano Server not all codepages are present
 def is_code_page_present(cp):
     from ctypes import POINTER, WINFUNCTYPE, WinDLL
-    from ctypes.wintypes import BOOL, UINT, BYTE, WCHAR, UINT, DWORD
+    from ctypes.wintypes import BOOL, BYTE, WCHAR, UINT, DWORD
 
     MAX_LEADBYTES = 12  # 5 ranges, 2 bytes ea., 0 term.
     MAX_DEFAULTCHAR = 2 # single or double byte
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 5f80a583450ea..9859d9a46710d 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -1023,7 +1023,7 @@ def test_func_kwargs(self):
         kwargs = (f'a{i}=x' for i in range(self.N))
         self.check_stack_size("f(" +  ", ".join(kwargs) + ")")
 
-    def test_func_args(self):
+    def test_meth_args(self):
         self.check_stack_size("o.m(" + "x, " * self.N + ")")
 
     def test_meth_kwargs(self):
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 54d100288cb62..8aad4a5967b34 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1465,7 +1465,7 @@ def test_dict_items_result_gc(self):
         self.assertTrue(gc.is_tracked(next(it)))
 
     @support.cpython_only
-    def test_dict_items_result_gc(self):
+    def test_dict_items_result_gc_reversed(self):
         # Same as test_dict_items_result_gc above, but reversed.
         it = reversed({None: []}.items())
         gc.collect()
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py
index 1bdcfa129b4c8..854f2ff009c61 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -395,7 +395,7 @@ def test_get_unstructured_without_trailing_whitespace_hang_case(self):
             [errors.InvalidHeaderDefect],
             '')
 
-    def test_get_unstructured_invalid_ew(self):
+    def test_get_unstructured_invalid_ew2(self):
         self._test_get_x(self._get_unst,
             '=?utf-8?q?=somevalue?=',
             '=?utf-8?q?=somevalue?=',
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index 0c178127571b0..0243b8a30b936 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -16,7 +16,6 @@
 import unittest
 
 import struct
-import tty
 import fcntl
 import warnings
 
diff --git a/Lib/test/test_tabnanny.py b/Lib/test/test_tabnanny.py
index 59fdfc5573d37..e0a82e95c486b 100644
--- a/Lib/test/test_tabnanny.py
+++ b/Lib/test/test_tabnanny.py
@@ -4,7 +4,6 @@
     * errored    : Whitespace related problems present in file.
 """
 from unittest import TestCase, mock
-from unittest import mock
 import errno
 import os
 import tabnanny



More information about the Python-checkins mailing list