Commit 6ca43f2d authored by Kirill Smelkov's avatar Kirill Smelkov

gpython: tests: test_pymain: Fix -i on PyPy3

On py3 'ps1' and b'ps1' are different keys and it was failing on PyPy3 as follows:

            # -i after stdin (also tests interactive mode as -i forces interactive even on non-tty)
            d = {
                b'hellopy': b(hellopy),
                b'ps1':     b'' # cpython emits prompt to stderr
            }
            if is_pypy and not is_gpython:
                d['ps1'] = b'>>>> ' # native pypy emits prompt to stdout and >>>> instead of >>>
            _ = pyout(['-i'], stdin=b'import hello\n', cwd=testdata)
    >       assert _ == b"%(ps1)shello\nworld\n['']\n%(ps1)s"           % d
    E       assert b">>>> hello\...\n['']\n>>>> " == b"hello\nworld\n['']\n"
    E         At index 0 diff: b'>' != b'h'
    E         Full diff:
    E         - b"hello\nworld\n['']\n"
    E         + b">>>> hello\nworld\n['']\n>>>> "
    E         ?   +++++                    +++++

    gpython/gpython_test.py:200: AssertionError

Fix it.
Amends e205dbf6 (gpython: Implement -i (interactive inspect after program run) + promised interactive-mode tests)
parent 58d4cbfe
...@@ -195,7 +195,7 @@ def test_pymain(): ...@@ -195,7 +195,7 @@ def test_pymain():
b'ps1': b'' # cpython emits prompt to stderr b'ps1': b'' # cpython emits prompt to stderr
} }
if is_pypy and not is_gpython: if is_pypy and not is_gpython:
d['ps1'] = b'>>>> ' # native pypy emits prompt to stdout and >>>> instead of >>> d[b'ps1'] = b'>>>> ' # native pypy emits prompt to stdout and >>>> instead of >>>
_ = pyout(['-i'], stdin=b'import hello\n', cwd=testdata) _ = pyout(['-i'], stdin=b'import hello\n', cwd=testdata)
assert _ == b"%(ps1)shello\nworld\n['']\n%(ps1)s" % d assert _ == b"%(ps1)shello\nworld\n['']\n%(ps1)s" % d
_ = pyout(['-i', '-'], stdin=b'import hello\n', cwd=testdata) _ = pyout(['-i', '-'], stdin=b'import hello\n', cwd=testdata)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment