-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
62 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Copyright (c) 2006 Zope Foundation and Contributors. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE | ||
# | ||
############################################################################## | ||
|
||
from RestrictedPython._compat import IS_PY2 | ||
from RestrictedPython._compat import IS_PY3 | ||
|
||
import pytest | ||
|
||
if IS_PY2: | ||
from RestrictedPython.RCompile import _niceParse | ||
import compiler | ||
|
||
pytestmark = pytest.mark.skipif( | ||
IS_PY3, | ||
reason="legacy tests against old implementation") | ||
|
||
|
||
source = u"u'Ä väry nice säntänce with umlauts.'" | ||
|
||
|
||
def test_unicode_source_exec(): | ||
assert isinstance(_niceParse(source, "test.py", "exec"), | ||
compiler.ast.Module) | ||
|
||
|
||
def test_unicode_source_single(): | ||
assert isinstance(_niceParse(source, "test.py", "single"), | ||
compiler.ast.Module) | ||
|
||
|
||
def test_unicode_source_eval(): | ||
assert isinstance(_niceParse(source, "test.py", "eval"), | ||
compiler.ast.Expression) |
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,18 @@ | ||
# -*- coding: utf-8 -*- | ||
import ast | ||
|
||
|
||
# Port of file: tests/testCompile.py | ||
|
||
def test_unicode_source(): | ||
""" | ||
Test if the AST Parsing works with Unicode source. | ||
""" | ||
# TODO: Review is that is really somethin we want to test this way. | ||
# ast.parse is a python core method and should be tested there. | ||
# RestrictedPython.RCompile _niceParse is not reimplemented. | ||
source = u"u'Ä väry nice säntänce with umlauts.'" | ||
|
||
assert isinstance(ast.parse(source, "test.py", "exec"), ast.Module) | ||
assert isinstance(ast.parse(source, "test.py", "single"), ast.Interactive) | ||
assert isinstance(ast.parse(source, "test.py", "eval"), ast.Expression) |