-
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.
Merge pull request #39 from zopefoundation/compile_tests
Compile tests of invalid options
- Loading branch information
Showing
15 changed files
with
132 additions
and
191 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
[run] | ||
branch = True | ||
source = RestrictedPython | ||
omit = | ||
src/RestrictedPython/tests | ||
src/RestrictedPython/tests/*.py | ||
tests/*.py | ||
bootstrap.py | ||
|
||
[report] | ||
precision = 3 |
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 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
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 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
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,72 @@ | ||
from RestrictedPython.Limits import _limited_list | ||
from RestrictedPython.Limits import _limited_range | ||
from RestrictedPython.Limits import _limited_tuple | ||
|
||
import pytest | ||
|
||
|
||
def test__limited_range_length_1(): | ||
result = _limited_range(1) | ||
assert result == range(0, 1) | ||
|
||
|
||
def test__limited_range_length_10(): | ||
result = _limited_range(10) | ||
assert result == range(0, 10) | ||
|
||
|
||
def test__limited_range_5_10(): | ||
result = _limited_range(5, 10) | ||
assert result == range(5, 10) | ||
|
||
|
||
def test__limited_range_5_10_sm1(): | ||
result = _limited_range(5, 10, -1) | ||
assert result == range(5, 10, -1) | ||
|
||
|
||
def test__limited_range_15_10_s2(): | ||
result = _limited_range(15, 10, 2) | ||
assert result == range(15, 10, 2) | ||
|
||
|
||
def test__limited_range_no_input(): | ||
with pytest.raises(TypeError): | ||
_limited_range() | ||
|
||
|
||
def test__limited_range_more_steps(): | ||
with pytest.raises(AttributeError): | ||
_limited_range(0, 0, 0, 0) | ||
|
||
|
||
def test__limited_range_zero_step(): | ||
with pytest.raises(ValueError): | ||
_limited_range(0, 10, 0) | ||
|
||
|
||
def test__limited_range_range_overflow(): | ||
with pytest.raises(ValueError): | ||
_limited_range(0, 5000, 1) | ||
|
||
|
||
def test__limited_list_valid_list_input(): | ||
input = [1, 2, 3] | ||
result = _limited_list(input) | ||
assert result == input | ||
|
||
|
||
def test__limited_list_invalid_string_input(): | ||
with pytest.raises(TypeError): | ||
_limited_list('input') | ||
|
||
|
||
def test__limited_tuple_valid_list_input(): | ||
input = [1, 2, 3] | ||
result = _limited_tuple(input) | ||
assert result == tuple(input) | ||
|
||
|
||
def test__limited_tuple_invalid_string_input(): | ||
with pytest.raises(TypeError): | ||
_limited_tuple('input') |
File renamed without changes.
Oops, something went wrong.