mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
*sigh* deal with instances correctly
This commit is contained in:
parent
0a32f9c448
commit
784d455066
2 changed files with 18 additions and 1 deletions
|
@ -141,6 +141,12 @@ class TestReversed(unittest.TestCase):
|
|||
# don't allow keyword arguments
|
||||
self.assertRaises(TypeError, reversed, [], a=1)
|
||||
|
||||
def test_class_class(self):
|
||||
class A:
|
||||
def __reversed__(self):
|
||||
return [2, 1]
|
||||
self.assertEqual(list(reversed(A())), [2, 1])
|
||||
|
||||
def test_xrange_optimization(self):
|
||||
x = xrange(1)
|
||||
self.assertEqual(type(reversed(x)), type(iter(x)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue