Skip to content

Commit

Permalink
[3.11] Enable ruff on several more files in Lib/test (python#110929)
Browse files Browse the repository at this point in the history
(cherry-picked from commit 02d26c4)
  • Loading branch information
AlexWaygood committed Oct 16, 2023
1 parent 6502a13 commit a1bbd1f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
10 changes: 5 additions & 5 deletions Lib/ctypes/test/test_arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ def test_bad_subclass(self):
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):
Expand All @@ -190,15 +190,15 @@ class T(Array):
_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

Expand Down
6 changes: 3 additions & 3 deletions Lib/ctypes/test/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ class X(object, Array):

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')
Expand Down
3 changes: 0 additions & 3 deletions Lib/test/.ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_genericclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __mro_entries__(self):
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:
Expand All @@ -111,7 +111,7 @@ def __mro_entries__(self):
return object
c = C_not_tuple()
with self.assertRaises(TypeError):
class D(c): ...
class E(c): ...

def test_mro_entry_metaclass(self):
meta_args = []
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_keywordonlyarg.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def f(v=a, x=b, *, y=c, z=d):
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")


Expand Down
10 changes: 5 additions & 5 deletions Lib/test/test_subclassinit.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def __init__(self, name, bases, namespace, otherarg):
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):
Expand All @@ -243,10 +243,10 @@ def __init__(self, name, bases, namespace, otherarg):
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
Expand All @@ -265,10 +265,10 @@ def __new__(cls, name, bases, namespace, otherarg):
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,), {})
Expand Down

0 comments on commit a1bbd1f

Please sign in to comment.