Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove already ported tests. * Rename tests to match the methods they test. * Move tests around nearer to the code they test. * Add a missing visitor.
- Loading branch information
Michael Howitz
committed
Jan 31, 2017
1 parent
da3956d
commit c4ca8c4
Showing
5 changed files
with
44 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from RestrictedPython._compat import IS_PY2 | ||
import RestrictedPython | ||
|
||
# Define the arguments for @pytest.mark.parametrize to be able to test both the | ||
# old and the new implementation to be equal: | ||
compile = ('compile', [RestrictedPython.compile.compile_restricted_exec]) | ||
if IS_PY2: | ||
from RestrictedPython import RCompile | ||
compile[1].append(RCompile.compile_restricted_exec) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from . import compile | ||
from RestrictedPython._compat import IS_PY2 | ||
import pytest | ||
|
||
|
||
EXEC_STATEMENT = """\ | ||
def no_exec(): | ||
exec 'q = 1' | ||
""" | ||
|
||
|
||
@pytest.mark.skipif( | ||
IS_PY2, | ||
reason="exec statement in Python 2 is handled by RestrictedPython ") | ||
@pytest.mark.parametrize(*compile) | ||
def test_compile__compile_restricted_exec__10(compile): | ||
"""It is a SyntaxError to use the `exec` statement. (Python 3 only)""" | ||
code, errors, warnings, used_names = compile(EXEC_STATEMENT) | ||
assert ( | ||
"Line 2: SyntaxError: Missing parentheses in call to 'exec' in on " | ||
"statement: exec 'q = 1'",) == errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters