-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add some tests for features new in 2.5 and 2.6
- Loading branch information
Showing
7 changed files
with
150 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -400,4 +400,3 @@ def visitImport(self, node, walker): | |
if asname: | ||
self.checkName(node, asname) | ||
return node | ||
|
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,34 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2008 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# 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. | ||
# | ||
############################################################################## | ||
"""Restricted Python transformation examples | ||
This module contains pairs of functions. Each pair has a before and an | ||
after function. The after function shows the source code equivalent | ||
of the before function after it has been modified by the restricted | ||
compiler. | ||
These examples are actually used in the testRestrictions.py | ||
checkBeforeAndAfter() unit tests, which verifies that the restricted compiler | ||
actually produces the same output as would be output by the normal compiler | ||
for the after function. | ||
$Id: before_and_after24.py 76322 2007-06-04 17:40:03Z philikon $ | ||
""" | ||
|
||
def simple_ternary_if_before(): | ||
x.y = y.z if y.z else y.x | ||
|
||
def simple_ternary_if_after(): | ||
_write_(x).y = _getattr_(y, 'z') if _getattr_(y, 'z') else _getattr_(y, 'x') | ||
|
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,51 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2008 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# 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. | ||
# | ||
############################################################################## | ||
"""Restricted Python transformation examples | ||
This module contains pairs of functions. Each pair has a before and an | ||
after function. The after function shows the source code equivalent | ||
of the before function after it has been modified by the restricted | ||
compiler. | ||
These examples are actually used in the testRestrictions.py | ||
checkBeforeAndAfter() unit tests, which verifies that the restricted compiler | ||
actually produces the same output as would be output by the normal compiler | ||
for the after function. | ||
$Id: before_and_after24.py 76322 2007-06-04 17:40:03Z philikon $ | ||
""" | ||
|
||
def simple_context_before(): | ||
with whatever as x: | ||
x.y = z | ||
|
||
def simple_context_after(): | ||
with whatever as x: | ||
_write_(x).y = z | ||
|
||
def simple_context_assign_attr_before(): | ||
with whatever as x.y: | ||
x.y = z | ||
|
||
def simple_context_assign_attr_after(): | ||
with whatever as _write_(x).y: | ||
_write_(x).y = z | ||
|
||
def simple_context_load_attr_before(): | ||
with whatever.w as z: | ||
x.y = z | ||
|
||
def simple_context_load_attr_after(): | ||
with _getattr_(whatever, 'w') as z: | ||
_write_(x).y = z |
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,7 @@ | ||
# These are all supposed to raise a SyntaxError when using | ||
# compile_restricted() but not when using compile(). | ||
# Each function in this module is compiled using compile_restricted(). | ||
|
||
def with_as_bad_name(): | ||
with x as _leading_underscore: | ||
pass |
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