From 5f7aba938cf5007b6f95472a3a54732dd99a2df8 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 16 Oct 2023 21:17:59 +0100 Subject: [3.11] Enable ruff on several more files in `Lib/test` (#110929) (#110935) (cherry-picked from commit 02d26c4bef3ad0f9c97e47993a7fa67898842e5c) --- Lib/ctypes/test/test_arrays.py | 10 +++++----- Lib/ctypes/test/test_functions.py | 6 +++--- Lib/test/.ruff.toml | 3 --- Lib/test/test_genericclass.py | 4 ++-- Lib/test/test_keywordonlyarg.py | 2 +- Lib/test/test_subclassinit.py | 10 +++++----- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/ctypes/test/test_arrays.py index 14603b7..a653877 100644 --- a/Lib/ctypes/test/test_arrays.py +++ b/Lib/ctypes/test/test_arrays.py @@ -178,10 +178,10 @@ class ArrayTestCase(unittest.TestCase): class T(Array): pass with self.assertRaises(AttributeError): - class T(Array): + class T2(Array): _type_ = c_int with self.assertRaises(AttributeError): - class T(Array): + class T3(Array): _length_ = 13 def test_bad_length(self): @@ -190,15 +190,15 @@ class ArrayTestCase(unittest.TestCase): _type_ = c_int _length_ = - sys.maxsize * 2 with self.assertRaises(ValueError): - class T(Array): + class T2(Array): _type_ = c_int _length_ = -1 with self.assertRaises(TypeError): - class T(Array): + class T3(Array): _type_ = c_int _length_ = 1.87 with self.assertRaises(OverflowError): - class T(Array): + class T4(Array): _type_ = c_int _length_ = sys.maxsize * 2 diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py index fc57170..d1fbc32 100644 --- a/Lib/ctypes/test/test_functions.py +++ b/Lib/ctypes/test/test_functions.py @@ -42,16 +42,16 @@ class FunctionTestCase(unittest.TestCase): from _ctypes import _Pointer with self.assertRaises(TypeError): - class X(object, _Pointer): + class X2(object, _Pointer): pass from _ctypes import _SimpleCData with self.assertRaises(TypeError): - class X(object, _SimpleCData): + class X3(object, _SimpleCData): _type_ = "i" with self.assertRaises(TypeError): - class X(object, Structure): + class X4(object, Structure): _fields_ = [] @need_symbol('c_wchar') diff --git a/Lib/test/.ruff.toml b/Lib/test/.ruff.toml index 7ef5416..89e33b2 100644 --- a/Lib/test/.ruff.toml +++ b/Lib/test/.ruff.toml @@ -15,12 +15,9 @@ extend-exclude = [ "test_descr.py", "test_enum.py", "test_functools.py", - "test_genericclass.py", "test_grammar.py", "test_import/__init__.py", - "test_keywordonlyarg.py", "test_pkg.py", - "test_subclassinit.py", "test_tokenize.py", "test_yield_from.py", "time_hashlib.py", diff --git a/Lib/test/test_genericclass.py b/Lib/test/test_genericclass.py index d8bb37f..aece757 100644 --- a/Lib/test/test_genericclass.py +++ b/Lib/test/test_genericclass.py @@ -98,7 +98,7 @@ class TestMROEntry(unittest.TestCase): return () d = C_too_few() with self.assertRaises(TypeError): - class D(d): ... + class E(d): ... def test_mro_entry_errors_2(self): class C_not_callable: @@ -111,7 +111,7 @@ class TestMROEntry(unittest.TestCase): return object c = C_not_tuple() with self.assertRaises(TypeError): - class D(c): ... + class E(c): ... def test_mro_entry_metaclass(self): meta_args = [] diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py index df82f67..918f953 100644 --- a/Lib/test/test_keywordonlyarg.py +++ b/Lib/test/test_keywordonlyarg.py @@ -170,7 +170,7 @@ class KeywordOnlyArgTestCase(unittest.TestCase): pass self.assertEqual(str(err.exception), "name 'b' is not defined") with self.assertRaises(NameError) as err: - f = lambda v=a, x=b, *, y=c, z=d: None + g = lambda v=a, x=b, *, y=c, z=d: None self.assertEqual(str(err.exception), "name 'b' is not defined") diff --git a/Lib/test/test_subclassinit.py b/Lib/test/test_subclassinit.py index 0ad7d17..de3e4bb 100644 --- a/Lib/test/test_subclassinit.py +++ b/Lib/test/test_subclassinit.py @@ -232,7 +232,7 @@ class Test(unittest.TestCase): super().__init__(name, bases, namespace) with self.assertRaises(TypeError): - class MyClass(metaclass=MyMeta, otherarg=1): + class MyClass2(metaclass=MyMeta, otherarg=1): pass class MyMeta(type): @@ -243,10 +243,10 @@ class Test(unittest.TestCase): super().__init__(name, bases, namespace) self.otherarg = otherarg - class MyClass(metaclass=MyMeta, otherarg=1): + class MyClass3(metaclass=MyMeta, otherarg=1): pass - self.assertEqual(MyClass.otherarg, 1) + self.assertEqual(MyClass3.otherarg, 1) def test_errors_changed_pep487(self): # These tests failed before Python 3.6, PEP 487 @@ -265,10 +265,10 @@ class Test(unittest.TestCase): self.otherarg = otherarg return self - class MyClass(metaclass=MyMeta, otherarg=1): + class MyClass2(metaclass=MyMeta, otherarg=1): pass - self.assertEqual(MyClass.otherarg, 1) + self.assertEqual(MyClass2.otherarg, 1) def test_type(self): t = type('NewClass', (object,), {}) -- cgit v0.12