mirror of https://github.com/python/cpython
Enable ruff on several more files in `Lib/test` (#110929)
This commit is contained in:
parent
a1ac5590e0
commit
02d26c4bef
|
@ -12,18 +12,13 @@ extend-exclude = [
|
||||||
"encoded_modules/module_koi8_r.py",
|
"encoded_modules/module_koi8_r.py",
|
||||||
# TODO Fix: F811 Redefinition of unused name
|
# TODO Fix: F811 Redefinition of unused name
|
||||||
"test_buffer.py",
|
"test_buffer.py",
|
||||||
"test_ctypes/test_arrays.py",
|
|
||||||
"test_ctypes/test_functions.py",
|
|
||||||
"test_dataclasses/__init__.py",
|
"test_dataclasses/__init__.py",
|
||||||
"test_descr.py",
|
"test_descr.py",
|
||||||
"test_enum.py",
|
"test_enum.py",
|
||||||
"test_functools.py",
|
"test_functools.py",
|
||||||
"test_genericclass.py",
|
|
||||||
"test_grammar.py",
|
"test_grammar.py",
|
||||||
"test_import/__init__.py",
|
"test_import/__init__.py",
|
||||||
"test_keywordonlyarg.py",
|
|
||||||
"test_pkg.py",
|
"test_pkg.py",
|
||||||
"test_subclassinit.py",
|
|
||||||
"test_yield_from.py",
|
"test_yield_from.py",
|
||||||
"time_hashlib.py",
|
"time_hashlib.py",
|
||||||
]
|
]
|
||||||
|
|
|
@ -189,10 +189,10 @@ class ArrayTestCase(unittest.TestCase):
|
||||||
class T(Array):
|
class T(Array):
|
||||||
pass
|
pass
|
||||||
with self.assertRaises(AttributeError):
|
with self.assertRaises(AttributeError):
|
||||||
class T(Array):
|
class T2(Array):
|
||||||
_type_ = c_int
|
_type_ = c_int
|
||||||
with self.assertRaises(AttributeError):
|
with self.assertRaises(AttributeError):
|
||||||
class T(Array):
|
class T3(Array):
|
||||||
_length_ = 13
|
_length_ = 13
|
||||||
|
|
||||||
def test_bad_length(self):
|
def test_bad_length(self):
|
||||||
|
@ -201,15 +201,15 @@ class ArrayTestCase(unittest.TestCase):
|
||||||
_type_ = c_int
|
_type_ = c_int
|
||||||
_length_ = - sys.maxsize * 2
|
_length_ = - sys.maxsize * 2
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
class T(Array):
|
class T2(Array):
|
||||||
_type_ = c_int
|
_type_ = c_int
|
||||||
_length_ = -1
|
_length_ = -1
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
class T(Array):
|
class T3(Array):
|
||||||
_type_ = c_int
|
_type_ = c_int
|
||||||
_length_ = 1.87
|
_length_ = 1.87
|
||||||
with self.assertRaises(OverflowError):
|
with self.assertRaises(OverflowError):
|
||||||
class T(Array):
|
class T4(Array):
|
||||||
_type_ = c_int
|
_type_ = c_int
|
||||||
_length_ = sys.maxsize * 2
|
_length_ = sys.maxsize * 2
|
||||||
|
|
||||||
|
|
|
@ -46,15 +46,15 @@ class FunctionTestCase(unittest.TestCase):
|
||||||
_type_ = "i"
|
_type_ = "i"
|
||||||
|
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
class X(object, _Pointer):
|
class X2(object, _Pointer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
class X(object, _SimpleCData):
|
class X3(object, _SimpleCData):
|
||||||
_type_ = "i"
|
_type_ = "i"
|
||||||
|
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
class X(object, Structure):
|
class X4(object, Structure):
|
||||||
_fields_ = []
|
_fields_ = []
|
||||||
|
|
||||||
def test_c_char_parm(self):
|
def test_c_char_parm(self):
|
||||||
|
|
|
@ -98,7 +98,7 @@ class TestMROEntry(unittest.TestCase):
|
||||||
return ()
|
return ()
|
||||||
d = C_too_few()
|
d = C_too_few()
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
class D(d): ...
|
class E(d): ...
|
||||||
|
|
||||||
def test_mro_entry_errors_2(self):
|
def test_mro_entry_errors_2(self):
|
||||||
class C_not_callable:
|
class C_not_callable:
|
||||||
|
@ -111,7 +111,7 @@ class TestMROEntry(unittest.TestCase):
|
||||||
return object
|
return object
|
||||||
c = C_not_tuple()
|
c = C_not_tuple()
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
class D(c): ...
|
class E(c): ...
|
||||||
|
|
||||||
def test_mro_entry_metaclass(self):
|
def test_mro_entry_metaclass(self):
|
||||||
meta_args = []
|
meta_args = []
|
||||||
|
|
|
@ -170,7 +170,7 @@ class KeywordOnlyArgTestCase(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
self.assertEqual(str(err.exception), "name 'b' is not defined")
|
self.assertEqual(str(err.exception), "name 'b' is not defined")
|
||||||
with self.assertRaises(NameError) as err:
|
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")
|
self.assertEqual(str(err.exception), "name 'b' is not defined")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ class Test(unittest.TestCase):
|
||||||
super().__init__(name, bases, namespace)
|
super().__init__(name, bases, namespace)
|
||||||
|
|
||||||
with self.assertRaises(TypeError):
|
with self.assertRaises(TypeError):
|
||||||
class MyClass(metaclass=MyMeta, otherarg=1):
|
class MyClass2(metaclass=MyMeta, otherarg=1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class MyMeta(type):
|
class MyMeta(type):
|
||||||
|
@ -241,10 +241,10 @@ class Test(unittest.TestCase):
|
||||||
super().__init__(name, bases, namespace)
|
super().__init__(name, bases, namespace)
|
||||||
self.otherarg = otherarg
|
self.otherarg = otherarg
|
||||||
|
|
||||||
class MyClass(metaclass=MyMeta, otherarg=1):
|
class MyClass3(metaclass=MyMeta, otherarg=1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertEqual(MyClass.otherarg, 1)
|
self.assertEqual(MyClass3.otherarg, 1)
|
||||||
|
|
||||||
def test_errors_changed_pep487(self):
|
def test_errors_changed_pep487(self):
|
||||||
# These tests failed before Python 3.6, PEP 487
|
# These tests failed before Python 3.6, PEP 487
|
||||||
|
@ -263,10 +263,10 @@ class Test(unittest.TestCase):
|
||||||
self.otherarg = otherarg
|
self.otherarg = otherarg
|
||||||
return self
|
return self
|
||||||
|
|
||||||
class MyClass(metaclass=MyMeta, otherarg=1):
|
class MyClass2(metaclass=MyMeta, otherarg=1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.assertEqual(MyClass.otherarg, 1)
|
self.assertEqual(MyClass2.otherarg, 1)
|
||||||
|
|
||||||
def test_type(self):
|
def test_type(self):
|
||||||
t = type('NewClass', (object,), {})
|
t = type('NewClass', (object,), {})
|
||||||
|
|
Loading…
Reference in New Issue