Skip to content

Commit b8e5b1b

Browse files
authored
[3.12] Enable ruff on several more files in Lib/test (#110929) (#110934)
(cherry-picked from commit 02d26c4)
1 parent 89f9c22 commit b8e5b1b

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

Lib/test/.ruff.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@ extend-exclude = [
2020
"test_buffer.py",
2121
"test_capi/test_misc.py",
2222
"test_capi/test_unicode.py",
23-
"test_ctypes/test_arrays.py",
24-
"test_ctypes/test_functions.py",
2523
"test_dataclasses/__init__.py",
2624
"test_descr.py",
2725
"test_enum.py",
2826
"test_functools.py",
29-
"test_genericclass.py",
3027
"test_grammar.py",
3128
"test_import/__init__.py",
32-
"test_keywordonlyarg.py",
3329
"test_lib2to3/data/py3_test_grammar.py",
3430
"test_pkg.py",
35-
"test_subclassinit.py",
3631
"test_tokenize.py",
3732
"test_yield_from.py",
3833
"time_hashlib.py",

Lib/test/test_ctypes/test_arrays.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ def test_bad_subclass(self):
178178
class T(Array):
179179
pass
180180
with self.assertRaises(AttributeError):
181-
class T(Array):
181+
class T2(Array):
182182
_type_ = c_int
183183
with self.assertRaises(AttributeError):
184-
class T(Array):
184+
class T3(Array):
185185
_length_ = 13
186186

187187
def test_bad_length(self):
@@ -190,15 +190,15 @@ class T(Array):
190190
_type_ = c_int
191191
_length_ = - sys.maxsize * 2
192192
with self.assertRaises(ValueError):
193-
class T(Array):
193+
class T2(Array):
194194
_type_ = c_int
195195
_length_ = -1
196196
with self.assertRaises(TypeError):
197-
class T(Array):
197+
class T3(Array):
198198
_type_ = c_int
199199
_length_ = 1.87
200200
with self.assertRaises(OverflowError):
201-
class T(Array):
201+
class T4(Array):
202202
_type_ = c_int
203203
_length_ = sys.maxsize * 2
204204

Lib/test/test_ctypes/test_functions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ class X(object, Array):
4242

4343
from _ctypes import _Pointer
4444
with self.assertRaises(TypeError):
45-
class X(object, _Pointer):
45+
class X2(object, _Pointer):
4646
pass
4747

4848
from _ctypes import _SimpleCData
4949
with self.assertRaises(TypeError):
50-
class X(object, _SimpleCData):
50+
class X3(object, _SimpleCData):
5151
_type_ = "i"
5252

5353
with self.assertRaises(TypeError):
54-
class X(object, Structure):
54+
class X4(object, Structure):
5555
_fields_ = []
5656

5757
def test_c_char_parm(self):

Lib/test/test_genericclass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __mro_entries__(self):
9898
return ()
9999
d = C_too_few()
100100
with self.assertRaises(TypeError):
101-
class D(d): ...
101+
class E(d): ...
102102

103103
def test_mro_entry_errors_2(self):
104104
class C_not_callable:
@@ -111,7 +111,7 @@ def __mro_entries__(self):
111111
return object
112112
c = C_not_tuple()
113113
with self.assertRaises(TypeError):
114-
class D(c): ...
114+
class E(c): ...
115115

116116
def test_mro_entry_metaclass(self):
117117
meta_args = []

Lib/test/test_keywordonlyarg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def f(v=a, x=b, *, y=c, z=d):
170170
pass
171171
self.assertEqual(str(err.exception), "name 'b' is not defined")
172172
with self.assertRaises(NameError) as err:
173-
f = lambda v=a, x=b, *, y=c, z=d: None
173+
g = lambda v=a, x=b, *, y=c, z=d: None
174174
self.assertEqual(str(err.exception), "name 'b' is not defined")
175175

176176

Lib/test/test_subclassinit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def __init__(self, name, bases, namespace, otherarg):
230230
super().__init__(name, bases, namespace)
231231

232232
with self.assertRaises(TypeError):
233-
class MyClass(metaclass=MyMeta, otherarg=1):
233+
class MyClass2(metaclass=MyMeta, otherarg=1):
234234
pass
235235

236236
class MyMeta(type):
@@ -241,10 +241,10 @@ def __init__(self, name, bases, namespace, otherarg):
241241
super().__init__(name, bases, namespace)
242242
self.otherarg = otherarg
243243

244-
class MyClass(metaclass=MyMeta, otherarg=1):
244+
class MyClass3(metaclass=MyMeta, otherarg=1):
245245
pass
246246

247-
self.assertEqual(MyClass.otherarg, 1)
247+
self.assertEqual(MyClass3.otherarg, 1)
248248

249249
def test_errors_changed_pep487(self):
250250
# These tests failed before Python 3.6, PEP 487
@@ -263,10 +263,10 @@ def __new__(cls, name, bases, namespace, otherarg):
263263
self.otherarg = otherarg
264264
return self
265265

266-
class MyClass(metaclass=MyMeta, otherarg=1):
266+
class MyClass2(metaclass=MyMeta, otherarg=1):
267267
pass
268268

269-
self.assertEqual(MyClass.otherarg, 1)
269+
self.assertEqual(MyClass2.otherarg, 1)
270270

271271
def test_type(self):
272272
t = type('NewClass', (object,), {})

0 commit comments

Comments
 (0)