From 1df1c2732424798244d93a2391da03e96959df23 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Thu, 30 Dec 2021 03:25:15 +0300 Subject: [PATCH 1/2] bpo-46198: unskip one test in `test_email` --- Lib/test/test_email/test__header_value_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py index 1bdcfa129b4c87..854f2ff009c618 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?=', From b131120f335e096d8c8533790be5832a2c0e7337 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 1 Jan 2022 12:30:04 +0300 Subject: [PATCH 2/2] Remove more duplicates and unused code from tests --- Lib/test/datetimetester.py | 4 ---- Lib/test/support/__init__.py | 6 +++--- Lib/test/test_asyncio/test_sslproto.py | 1 - Lib/test/test_codecs.py | 2 +- Lib/test/test_compile.py | 2 +- Lib/test/test_dict.py | 2 +- Lib/test/test_enum.py | 2 +- Lib/test/test_pty.py | 1 - Lib/test/test_tabnanny.py | 1 - Lib/test/test_typing.py | 2 +- 10 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index 810478c7db2bea..df3764d61b1869 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -1864,8 +1864,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): @@ -3988,8 +3986,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 ca903d302bdd31..535eb6c7c9606e 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -1395,9 +1395,6 @@ def __init__(self, link=None): self._platform_specific() - def _platform_specific(self): - pass - if sys.platform == "win32": def _platform_specific(self): import glob @@ -1425,6 +1422,9 @@ def _platform_specific(self): self._env["PYTHONHOME"] = os.path.dirname(self.real) if sysconfig.is_python_build(True): self._env["PYTHONPATH"] = STDLIB_DIR + 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 22a216a83e3f92..f7411a8142cc87 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 4ad24dbb9a9243..2393b52085eb8a 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -36,7 +36,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 e237156c75f8b5..ca70ab44d92b17 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -1176,7 +1176,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 66f5d56deeaaf8..01081bbc427ac4 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -1438,7 +1438,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_enum.py b/Lib/test/test_enum.py index 18cc2f30ce559b..c39e3fccfa2154 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -3700,7 +3700,7 @@ class Sillier(IntEnum): triple = 3 value = 4 -class TestHelpers(unittest.TestCase): +class TestInternals(unittest.TestCase): sunder_names = '_bad_', '_good_', '_what_ho_' dunder_names = '__mal__', '__bien__', '__que_que__' diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index 0c178127571b07..0243b8a30b9367 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 4dfbd2985d5b5a..ef2a26210cfe24 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 diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index c8a077e2f1ff55..834a6e8bb3f910 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4586,7 +4586,7 @@ class C: A.x = 5 self.assertEqual(C.x, 5) - def test_hash_eq(self): + def test_hash_eq_annotated(self): self.assertEqual(len({Annotated[int, 4, 5], Annotated[int, 4, 5]}), 1) self.assertNotEqual(Annotated[int, 4, 5], Annotated[int, 5, 4]) self.assertNotEqual(Annotated[int, 4, 5], Annotated[str, 4, 5])