Exemple #1
0
def test_reversed():
    reversed = py.builtin.reversed
    r = reversed("hello")
    assert iter(r) is r
    s = "".join(list(r))
    assert s == "olleh"
    assert list(reversed(list(reversed("hello")))) == ['h', 'e', 'l', 'l', 'o']
    py.test.raises(TypeError, reversed, reversed("hello"))
Exemple #2
0
def test_reversed():
    reversed = py.builtin.reversed
    r = reversed("hello")
    assert iter(r) is r
    s = "".join(list(r))
    assert s == "olleh"
    assert list(reversed(list(reversed("hello")))) == ['h','e','l','l','o']
    py.test.raises(TypeError, reversed, reversed("hello"))
Exemple #3
0
def test_reversed():
    r = reversed("hello")
    assert iter(r) is r
    assert r.next() == "o"
    assert r.next() == "l"
    assert r.next() == "l"
    assert r.next() == "e"
    assert r.next() == "h"
    raises(StopIteration, r.next)
    assert list(reversed(list(reversed("hello")))) == ['h','e','l','l','o']
    raises(TypeError, reversed, reversed("hello"))
Exemple #4
0
def test_reversed():
    r = reversed("hello")
    assert iter(r) is r
    assert r.next() == "o"
    assert r.next() == "l"
    assert r.next() == "l"
    assert r.next() == "e"
    assert r.next() == "h"
    raises(StopIteration, r.next)
    assert list(reversed(list(reversed("hello")))) == ['h', 'e', 'l', 'l', 'o']
    raises(TypeError, reversed, reversed("hello"))
Exemple #5
0
 def test_deque_reversed(self):
     it = reversed(self.d)
     raises(TypeError, len, it)
     assert it.next() == n-1
     assert it.next() == n-2
     self.d.pop()
     raises(RuntimeError, it.next)
 def test_deque_reversed(self):
     it = reversed(self.d)
     assert len(it) == n
     assert it.next() == n-1
     assert len(it) == n-1
     assert it.next() == n-2
     assert len(it) == n-2
     self.d.pop()
     raises(RuntimeError,it.next)
     assert len(it) == 0
     assert list(it) == []
Exemple #7
0
 def test_deque_reversed(self):
     it = reversed(self.d)
     assert len(it) == n
     assert it.next() == n - 1
     assert len(it) == n - 1
     assert it.next() == n - 2
     assert len(it) == n - 2
     self.d.pop()
     raises(RuntimeError, it.next)
     assert len(it) == 0
     assert list(it) == []