8000 gh-117797: Improve `test_descr.test_not_implemented` · sobolevn/cpython@dd9a9fc · GitHub
[go: up one dir, main page]

Skip to content

Commit dd9a9fc

Browse files
committed
pythongh-117797: Improve test_descr.test_not_implemented
1 parent fd259fd commit dd9a9fc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Lib/test/test_descr.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,14 +4594,13 @@ def test_special_unbound_method_types(self):
45944594
def test_not_implemented(self):
45954595
# Testing NotImplemented...
45964596
# all binary methods should be able to return a NotImplemented
4597-
import operator
45984597

45994598
def specialmethod(self, other):
46004599
return NotImplemented
46014600

46024601
def check(expr, x, y):
46034602
try:
4604-
exec(expr, {'x': x, 'y': y, 'operator': operator})
4603+
exec(expr, {'x': x, 'y': y})
46054604
except TypeError:
46064605
pass
46074606
else:
@@ -4632,6 +4631,13 @@ def check(expr, x, y):
46324631
check(expr, a, a)
46334632
check(expr, a, N1)
46344633
check(expr, a, N2)
4634+
B = type('B', (), {rname: specialmethod})
4635+
b = B()
4636+
check(expr, b, b)
4637+
check(expr, a, b)
4638+ check(expr, b, a)
4639+
check(expr, b, N1)
4640+
check(expr, b, N2)
46354641
if iexpr:
46364642
check(iexpr, a, a)
46374643
check(iexpr, a, N1)

0 commit comments

Comments
 (0)
0