Fix command compiler test (#1675)

This commit is contained in:
Hood Chatham 2021-06-29 19:11:01 -07:00 committed by GitHub
parent 447da28e80
commit ee25dc729c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -14,24 +14,24 @@ from pyodide import CodeRunner
def test_command_compiler():
c = _CodeRunnerCompile()
with pytest.raises(SyntaxError, match="unexpected EOF while parsing"):
c("def test():\n 1", "<input>", "exec")
assert isinstance(c("def test():\n 1\n", "<input>", "exec"), CodeRunner)
c("def test():\n 1", "<input>", "single")
assert isinstance(c("def test():\n 1\n", "<input>", "single"), CodeRunner)
with pytest.raises(SyntaxError, match="invalid syntax"):
c("1<>2", "<input>", "exec")
c("1<>2", "<input>", "single")
assert isinstance(
c("from __future__ import barry_as_FLUFL", "<input>", "exec"), CodeRunner
c("from __future__ import barry_as_FLUFL", "<input>", "single"), CodeRunner
)
assert isinstance(c("1<>2", "<input>", "exec"), CodeRunner)
assert isinstance(c("1<>2", "<input>", "single"), CodeRunner)
c = _CodeRunnerCommandCompiler()
assert c("def test():\n 1", "<input>", "exec") is None
assert isinstance(c("def test():\n 1\n", "<input>", "exec"), CodeRunner)
assert c("def test():\n 1", "<input>", "single") is None
assert isinstance(c("def test():\n 1\n", "<input>", "single"), CodeRunner)
with pytest.raises(SyntaxError, match="invalid syntax"):
c("1<>2", "<input>", "exec")
c("1<>2", "<input>", "single")
assert isinstance(
c("from __future__ import barry_as_FLUFL", "<input>", "exec"), CodeRunner
c("from __future__ import barry_as_FLUFL", "<input>", "single"), CodeRunner
)
assert isinstance(c("1<>2", "<input>", "exec"), CodeRunner)
assert isinstance(c("1<>2", "<input>", "single"), CodeRunner)
def test_stream_redirection():