Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple test failures with PyPy 7.2.0 #530

Open
mgorny opened this issue Nov 15, 2019 · 0 comments
Open

Multiple test failures with PyPy 7.2.0 #530

mgorny opened this issue Nov 15, 2019 · 0 comments

Comments

@mgorny
Copy link
Contributor

mgorny commented Nov 15, 2019

Since this became a dep for PyContracts, I've tried running the tests on PyPy 7.2.0, and I've gotten a number of test failures:

==================================================================== FAILURES =====================================================================
____________________________________________________________ TestChainMap.test_basics _____________________________________________________________

self = <test_future.test_backports.TestChainMap testMethod=test_basics>

    def test_basics(self):
        c = ChainMap()
        c['a'] = 1
        c['b'] = 2
        d = c.new_child()
        d['b'] = 20
        d['c'] = 30
        self.assertEqual(d.maps, [{'b':20, 'c':30}, {'a':1, 'b':2}])  # check internal state
>       self.assertEqual(d.items(), dict(a=1, b=20, c=30).items())    # check items/iter/getitem
E       AssertionError: Lists differ: [('b', 20), ('c', 30), ('a', 1... != [('a', 1), ('b', 20), ('c', 30...
E       
E       First differing element 0:
E       ('b', 20)
E       ('a', 1)
E       
E       - [('b', 20), ('c', 30), ('a', 1)]
E       + [('a', 1), ('b', 20), ('c', 30)]

tests/test_future/test_backports.py:90: AssertionError
__________________________________________________________ BuiltinTest.test_exec_globals __________________________________________________________

self = <test_future.test_builtins.BuiltinTest testMethod=test_exec_globals>

    def test_exec_globals(self):
        code = compile("print('Hello World!')", "", "exec")
        # no builtin function
        # Was:
        # self.assertRaisesRegex(NameError, "name 'print' is not defined",
        #                        exec_, code, {'__builtins__': {}})
        # Now:
        self.assertRaises(NameError,
>                         exec_, code, {'__builtins__': {}})
E       AssertionError: NameError not raised

tests/test_future/test_builtins.py:788: AssertionError
-------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------
Hello World!
__________________________________________________________ BuiltinTest.test_general_eval __________________________________________________________

self = <test_future.test_builtins.BuiltinTest testMethod=test_general_eval>

    def test_general_eval(self):
        # Tests that general mappings can be used for the locals argument
    
        class M:
            "Test mapping interface versus possible calls from eval()."
            def __getitem__(self, key):
                if key == 'a':
                    return 12
                raise KeyError
            def keys(self):
                return list('xyz')
    
        m = M()
        g = globals()
        self.assertEqual(eval('a', g, m), 12)
        self.assertRaises(NameError, eval, 'b', g, m)
        self.assertEqual(eval('dir()', g, m), list('xyz'))
        self.assertEqual(eval('globals()', g, m), g)
        self.assertEqual(eval('locals()', g, m), m)
>       self.assertRaises(TypeError, eval, 'a', m)
E       AssertionError: TypeError not raised

tests/test_future/test_builtins.py:702: AssertionError
____________________________________________ TestIsInstanceIsSubclass.test_isinstance_recursion_limit _____________________________________________

self = <test_future.test_isinstance.TestIsInstanceIsSubclass testMethod=test_isinstance_recursion_limit>

    def test_isinstance_recursion_limit(self):
        # make sure that issubclass raises RuntimeError before the C stack is
        # blown
>       self.assertRaises(RuntimeError, blowstack, isinstance, '', str)
E       AssertionError: RuntimeError not raised

tests/test_future/test_isinstance.py:275: AssertionError
_____________________________________________ TestIsInstanceIsSubclass.test_subclass_recursion_limit ______________________________________________

self = <test_future.test_isinstance.TestIsInstanceIsSubclass testMethod=test_subclass_recursion_limit>

    def test_subclass_recursion_limit(self):
        # make sure that issubclass raises RuntimeError before the C stack is
        # blown
>       self.assertRaises(RuntimeError, blowstack, issubclass, str, str)
E       AssertionError: RuntimeError not raised

tests/test_future/test_isinstance.py:270: AssertionError
________________________________________________________________ TestStr.test_mul _________________________________________________________________

self = <test_future.test_str.TestStr testMethod=test_mul>

    def test_mul(self):
        s = str(u'ABC')
        c = s * 4
        self.assertTrue(isinstance(c, str))
        self.assertEqual(c, u'ABCABCABCABC')
        d = s * int(4)
        self.assertTrue(isinstance(d, str))
        self.assertEqual(d, u'ABCABCABCABC')
        if utils.PY2:
            e = s * long(4)
            self.assertTrue(isinstance(e, str))
            self.assertEqual(e, u'ABCABCABCABC')
        with self.assertRaises(TypeError):
>           s * 3.3
E           AssertionError: TypeError not raised

tests/test_future/test_str.py:434: AssertionError
________________________________________________________________ TestStr.test_rmul ________________________________________________________________

self = <test_future.test_str.TestStr testMethod=test_rmul>

    def test_rmul(self):
        s = str(u'XYZ')
        c = 3 * s
        self.assertTrue(isinstance(c, str))
        self.assertEqual(c, u'XYZXYZXYZ')
        d = s * int(3)
        self.assertTrue(isinstance(d, str))
        self.assertEqual(d, u'XYZXYZXYZ')
        if utils.PY2:
            e = long(3) * s
            self.assertTrue(isinstance(e, str))
            self.assertEqual(e, u'XYZXYZXYZ')
        with self.assertRaises(TypeError):
>           3.3 * s
E           AssertionError: TypeError not raised

tests/test_future/test_str.py:451: AssertionError
_______________________________________________________ TestStr.test_str_join_staticmethod ________________________________________________________

self = <test_future.test_str.TestStr testMethod=test_str_join_staticmethod>

    def test_str_join_staticmethod(self):
        """
        Issue #33
        """
>       c = str.join('-', ['a', 'b'])
E       TypeError: unbound method join() must be called with newstr instance as first argument (got unicode instance instead)

tests/test_future/test_str.py:208: TypeError
__________________________________________________________ BuiltinTest.test_general_eval __________________________________________________________

self = <test_past.test_builtins.BuiltinTest testMethod=test_general_eval>

    @expectedFailurePY3
    def test_general_eval(self):
        # Tests that general mappings can be used for the locals argument
    
        class M:
            "Test mapping interface versus possible calls from eval()."
            def __getitem__(self, key):
                if key == 'a':
                    return 12
                raise KeyError
            def keys(self):
                return list('xyz')
    
        m = M()
        g = globals()
        self.assertEqual(eval('a', g, m), 12)
        self.assertRaises(NameError, eval, 'b', g, m)
        self.assertEqual(eval('dir()', g, m), list('xyz'))
        self.assertEqual(eval('globals()', g, m), g)
        self.assertEqual(eval('locals()', g, m), m)
>       self.assertRaises(TypeError, eval, 'a', m)
E       AssertionError: TypeError not raised

tests/test_past/test_builtins.py:445: AssertionError
_____________________________________________________________ BuiltinTest.test_range ______________________________________________________________

self = <test_past.test_builtins.BuiltinTest testMethod=test_range>

    @skip26
    @expectedFailurePY3
    def test_range(self):
        self.assertEqual(range(3), [0, 1, 2])
        self.assertEqual(range(1, 5), [1, 2, 3, 4])
        self.assertEqual(range(0), [])
        self.assertEqual(range(-3), [])
        self.assertEqual(range(1, 10, 3), [1, 4, 7])
        self.assertEqual(range(5, -5, -3), [5, 2, -1, -4])
    
        # Now test range() with longs
        self.assertEqual(range(-2**100), [])
        self.assertEqual(range(0, -2**100), [])
        self.assertEqual(range(0, 2**100, -1), [])
        self.assertEqual(range(0, 2**100, -1), [])
    
        a = long(10 * sys.maxsize)
        b = long(100 * sys.maxsize)
        c = long(50 * sys.maxsize)
    
        self.assertEqual(range(a, a+2), [a, a+1])
        self.assertEqual(range(a+2, a, -1), [a+2, a+1])
        self.assertEqual(range(a+4, a, -2), [a+4, a+2])
    
        seq = range(a, b, c)
        self.assertIn(a, seq)
        self.assertNotIn(b, seq)
        self.assertEqual(len(seq), 2)
    
        seq = range(b, a, -c)
        self.assertIn(b, seq)
        self.assertNotIn(a, seq)
        self.assertEqual(len(seq), 2)
    
        seq = range(-a, -b, -c)
        self.assertIn(-a, seq)
        self.assertNotIn(-b, seq)
        self.assertEqual(len(seq), 2)
    
        self.assertRaises(TypeError, range)
        self.assertRaises(TypeError, range, 1, 2, 3, 4)
        self.assertRaises(ValueError, range, 1, 2, 0)
        self.assertRaises(ValueError, range, a, a + 1, long(0))
    
        class badzero(int):
            def __cmp__(self, other):
                raise RuntimeError
            __hash__ = None # Invalid cmp makes this unhashable
>       self.assertRaises(RuntimeError, range, a, a + 1, badzero(1))
E       AssertionError: RuntimeError not raised

tests/test_past/test_builtins.py:1177: AssertionError
_______________________________________________________ Py2DictTest.test_setdefault_atomic ________________________________________________________

self = <test_past.test_olddict.Py2DictTest testMethod=test_setdefault_atomic>

    @skip26
    def test_setdefault_atomic(self):
        # Issue #13521: setdefault() calls __hash__ and __eq__ only once.
        class Hashed(object):
            def __init__(self):
                self.hash_count = 0
                self.eq_count = 0
            def __hash__(self):
                self.hash_count += 1
                return 42
            def __eq__(self, other):
                self.eq_count += 1
                return id(self) == id(other)
        hashed1 = Hashed()
        y = dict({hashed1: 5})
        hashed2 = Hashed()
        y.setdefault(hashed2, [])
>       self.assertEqual(hashed1.hash_count, 1)
E       AssertionError: 2 != 1

tests/test_past/test_olddict.py:434: AssertionError
======================================== 11 failed, 1017 passed, 36 skipped, 62 xfailed in 209.78 seconds =========================================
mgorny added a commit to mgorny/python-future that referenced this issue Nov 15, 2019
Sort the results of items() of a dict before comparing them.  PyPy
apparently does not produce consistent ordering on .items().

Fixes one of the failures from bug PythonCharmers#530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant