*sigh* deal with instances correctly

This commit is contained in:
Benjamin Peterson 2009-05-09 17:23:03 +00:00
parent 0a32f9c448
commit 784d455066
2 changed files with 18 additions and 1 deletions

View file

@ -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)))