Exemple #1
0
 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(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]
Exemple #3
0
 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)
Exemple #5
0
 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)
Exemple #6
0
    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)
Exemple #7
0
 def __reversed__(self):
     return reversed_dict(self)
Exemple #8
0
 def __reversed__(self):
     return reversed_dict(self)
Exemple #9
0
 def __reversed__(self):
     for key in reversed_dict(self._dict):
         yield self._dict[key]
Exemple #10
0
 def __reversed__(self):
     yield from reversed_dict(self._dict)
Exemple #11
0
 def test_reversed(self):
     import __pypy__
     name = next(__pypy__.reversed_dict(__pypy__.__dict__))
     assert isinstance(name, str)
Exemple #12
0
 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)
Exemple #13
0
 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)
Exemple #16
0
 def test_reversed(self):
     import __pypy__
     name = next(__pypy__.reversed_dict(__pypy__.__dict__))
     assert isinstance(name, str)