]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Enable ruff on several more files in `Lib/test` (#110929) (#110934)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Mon, 16 Oct 2023 15:48:02 +0000 (16:48 +0100)
committerGitHub <noreply@github.com>
Mon, 16 Oct 2023 15:48:02 +0000 (15:48 +0000)
(cherry-picked from commit 02d26c4bef3ad0f9c97e47993a7fa67898842e5c)

Lib/test/.ruff.toml
Lib/test/test_ctypes/test_arrays.py
Lib/test/test_ctypes/test_functions.py
Lib/test/test_genericclass.py
Lib/test/test_keywordonlyarg.py
Lib/test/test_subclassinit.py

index 9b23c2610f938941b92626acd29cf76a733d920b..231b0e508f51c1278e8d8c6b34f28c06b567d805 100644 (file)
@@ -20,19 +20,14 @@ extend-exclude = [
     "test_buffer.py",
     "test_capi/test_misc.py",
     "test_capi/test_unicode.py",
-    "test_ctypes/test_arrays.py",
-    "test_ctypes/test_functions.py",
     "test_dataclasses/__init__.py",
     "test_descr.py",
     "test_enum.py",
     "test_functools.py",
-    "test_genericclass.py",
     "test_grammar.py",
     "test_import/__init__.py",
-    "test_keywordonlyarg.py",
     "test_lib2to3/data/py3_test_grammar.py",
     "test_pkg.py",
-    "test_subclassinit.py",
     "test_tokenize.py",
     "test_yield_from.py",
     "time_hashlib.py",
index 415a5785a9c1bb6a37c419699d2528a4d1908624..78aead26da78f3c0582341d283e4df8a71f2768d 100644 (file)
@@ -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
 
index 703bd2c601ccf66173dc7ac7da0cce0ad390abdf..bc7f211e53c22841fbf2a6d6a29ba07e92988208 100644 (file)
@@ -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_ = []
 
     def test_c_char_parm(self):
index d8bb37f69e18a1761580c3ab2e9d71872bb7ef90..aece757fc1933ec9022f7502f0b179fa62b4d082 100644 (file)
@@ -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 = []
index df82f677a00a48847c24fc58ab1a02bdc9ea383d..918f953cae57023f9a874dbea5c668979d51bb19 100644 (file)
@@ -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")
 
 
index 310473a4a2fe5834403821f36dceff1b2f607e29..0d32aa509bd25cde53da618bfa417e2cd23acbb9 100644 (file)
@@ -230,7 +230,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):
@@ -241,10 +241,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
@@ -263,10 +263,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,), {})