def test_reversed_dict(self): import __pypy__ class X(object): pass x = X(); x.a = 10; x.b = 20; x.c = 30 d = x.__dict__ assert list(__pypy__.reversed_dict(d)) == d.keys()[::-1]
def test_reversed_dict_runtimeerror(self): import __pypy__ d = {1: 2, 3: 4, 5: 6} it = __pypy__.reversed_dict(d) key = it.next() assert key in [1, 3, 5] # on CPython, dicts are not ordered del d[key] raises(RuntimeError, it.next)
def test_reversed_dict_runtimeerror(self): import __pypy__ d = {1: 2, 3: 4, 5: 6} it = __pypy__.reversed_dict(d) key = it.next() assert key in [1, 3, 5] del d[key] raises(RuntimeError, it.next)
def test_reversed_dict_runtimeerror(self): import __pypy__ d = {1: 2, 3: 4, 5: 6} it = __pypy__.reversed_dict(d) key = next(it) assert key in [1, 3, 5] del d[key] raises(RuntimeError, next, it)
def test_reversed_dict(self): import __pypy__ def kw(**d): return d for d in [{}, { 1: 2, 3: 4, 5: 6 }, { "a": 5, "b": 2, "c": 6 }, kw(a=1, b=2)]: assert list(__pypy__.reversed_dict(d)) == d.keys()[::-1] raises(TypeError, __pypy__.reversed_dict, 42)
def __reversed__(self): return reversed_dict(self)
def __reversed__(self): for key in reversed_dict(self._dict): yield self._dict[key]
def __reversed__(self): yield from reversed_dict(self._dict)
def test_reversed(self): import __pypy__ name = next(__pypy__.reversed_dict(__pypy__.__dict__)) assert isinstance(name, str)
def test_reversed_dict(self): import __pypy__ for d in [{}, {1: 2, 3: 4, 5: 6}, {"a": 5, "b": 2, "c": 6}]: assert list(__pypy__.reversed_dict(d)) == d.keys()[::-1] raises(TypeError, __pypy__.reversed_dict, 42)
def __reversed__(self): for key in reversed_dict(self._mapping): yield self._mapping[key]
def __reversed__(self): yield from reversed_dict(self._mapping)