Skip to content

Commit

Permalink
Revert "include tests in installed package (#232)" (#233)
Browse files Browse the repository at this point in the history
This reverts commit 84a5015 and
commit 4816526.

RestrictedPython intentionally does not include tests anymore

See discussion on #231
and #232
  • Loading branch information
perrinjerome committed Oct 12, 2022
1 parent 4816526 commit 8100312
Show file tree
Hide file tree
Showing 53 changed files with 64 additions and 83 deletions.
5 changes: 3 additions & 2 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ testenv-setenv = [
testenv-commands = [
"python -V",
"pip list",
"pytest --cov=src --cov-report= {posargs}",
"pytest --cov=src --cov=tests --cov-report= {posargs}",
]
testenv-additional = [
"",
Expand All @@ -51,7 +51,7 @@ testenv-additional = [
"depends = py36,py37,py38,py39,py39-datetime,py310,py311,coverage",
]
coverage-basepython = "python3.8"
coverage-command = "pytest --cov=src --cov-report= {posargs}"
coverage-command = "pytest --cov=src --cov=tests --cov-report= {posargs}"
coverage-setenv = [
"COVERAGE_FILE=.coverage",
]
Expand All @@ -64,6 +64,7 @@ additional-rules = [
"recursive-include docs *.ast",
"recursive-include docs *.bat",
"recursive-include docs *.jpg",
"recursive-include tests *.py",
]

[check-manifest]
Expand Down
3 changes: 0 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ Features

- Fix code to run on Python 3.11.0b3.

- Move ``tests`` directory into ``src``.
(`#232 <https://github.com/zopefoundation/RestrictedPython/pull/232>`_)


5.2 (2021-11-19)
----------------
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ recursive-include src *.py
recursive-include docs *.ast
recursive-include docs *.bat
recursive-include docs *.jpg
recursive-include tests *.py
Empty file.
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest

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)
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/RestrictedPython/tests/helper.py → tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import RestrictedPython.Guards
from RestrictedPython import compile_restricted_eval
from RestrictedPython import compile_restricted_exec

import RestrictedPython.Guards


def _compile(compile_func, source):
"""Compile some source with a compile func."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import pytest

from RestrictedPython import compile_restricted_exec
from RestrictedPython.Guards import guarded_unpack_sequence
from RestrictedPython.Guards import safe_builtins
from RestrictedPython.Guards import safe_globals
from RestrictedPython.Guards import safer_getattr
from tests.helper import restricted_eval
from tests.helper import restricted_exec

from .helper import restricted_eval
from .helper import restricted_exec
import pytest


def _write_(x):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

from ast import NodeTransformer
from ast import parse
from unittest import TestCase
from unittest import skipUnless

from RestrictedPython import compile_restricted
from RestrictedPython import safe_globals
from RestrictedPython._compat import IS_PY38_OR_GREATER
from unittest import skipUnless
from unittest import TestCase


@skipUnless(IS_PY38_OR_GREATER, "Feature available for Python 3.8+")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import platform
import types

import pytest

from RestrictedPython import CompileResult
from RestrictedPython import compile_restricted
from RestrictedPython import compile_restricted_eval
from RestrictedPython import compile_restricted_exec
from RestrictedPython import compile_restricted_single
from RestrictedPython import CompileResult
from RestrictedPython._compat import IS_PY38_OR_GREATER
from RestrictedPython._compat import IS_PY310_OR_GREATER
from tests.helper import restricted_eval

from .helper import restricted_eval
import platform
import pytest
import types


def test_compile__compile_restricted_invalid_code_input():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from types import FunctionType

from RestrictedPython import PrintCollector
from RestrictedPython import compile_restricted_function
from RestrictedPython import PrintCollector
from RestrictedPython import safe_builtins
from RestrictedPython._compat import IS_PY38_OR_GREATER
from RestrictedPython._compat import IS_PY310_OR_GREATER
from types import FunctionType


def test_compile_restricted_function():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from RestrictedPython.Eval import RestrictionCapableEval

import pytest


exp = """
{'a':[m.pop()]}['a'] \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
Tests about imports
"""

import pytest

from RestrictedPython import compile_restricted_exec
from RestrictedPython import safe_builtins
from tests.helper import restricted_exec

from .helper import restricted_exec
import pytest


OS_IMPORT_EXAMPLE = """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import pytest

from RestrictedPython import compile_restricted_exec
from RestrictedPython import safe_globals
from RestrictedPython.Eval import default_guarded_getiter
from RestrictedPython.Guards import guarded_iter_unpack_sequence

import pytest


ITERATE_OVER_DICT_ITEMS = """
d = {'a': 'b'}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import RestrictedPython
from RestrictedPython.PrintCollector import PrintCollector

import RestrictedPython


compiler = RestrictedPython.compile.compile_restricted_exec

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_eval

from ...helper import restricted_eval
from tests.helper import restricted_eval


# Arithmetic Operators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ...helper import restricted_eval
from tests.helper import restricted_eval


def test_BitAnd():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ...helper import restricted_eval
from tests.helper import restricted_eval


def test_Or():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ...helper import restricted_eval
from tests.helper import restricted_eval


def test_Eq():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ...helper import restricted_eval
from tests.helper import restricted_eval


def test_Is():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ...helper import restricted_eval
from tests.helper import restricted_eval


def test_In():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ...helper import restricted_eval
from tests.helper import restricted_eval


def test_UAdd():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..helper import restricted_exec
from tests.helper import restricted_exec


def test_RestrictingNodeTransformer__visit_Assert__1():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython.Guards import guarded_unpack_sequence

from ..helper import restricted_exec
from tests.helper import restricted_exec


def test_RestrictingNodeTransformer__visit_Assign__1(mocker):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_exec

from ..helper import restricted_exec
from tests.helper import restricted_exec


BAD_ATTR_UNDERSCORE = """\
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_exec

from ..helper import restricted_exec
from tests.helper import restricted_exec


def test_RestrictingNodeTransformer__visit_AugAssign__1(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_exec

from ..helper import restricted_eval
from tests.helper import restricted_eval


def test_Num():
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_exec

from ..helper import restricted_exec
from tests.helper import restricted_exec


def test_RestrictingNodeTransformer__visit_Call__1():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from RestrictedPython import compile_restricted_exec
from RestrictedPython.Guards import safe_builtins

from ..helper import restricted_exec
from tests.helper import restricted_exec


GOOD_CLASS = '''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..helper import restricted_eval
from tests.helper import restricted_eval


def test_RestrictingNodeTransformer__visit_Eq__1():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..helper import restricted_exec
from tests.helper import restricted_exec


def test_RestrictingNodeTransformer__test_ternary_if(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython._compat import IS_PY38_OR_GREATER

from ..helper import restricted_exec
from tests.helper import restricted_exec


DICT_COMPREHENSION_WITH_ATTRS = """
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest

from RestrictedPython import compile_restricted_exec
from RestrictedPython._compat import IS_PY38_OR_GREATER
from RestrictedPython.PrintCollector import PrintCollector

import pytest


def test_transform():
"""It compiles a function call successfully and returns the used name."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_RestrictingNodeTransformer__visit_FunctionDef__7():
assert result.errors == (functiondef_err_msg,)



BLACKLISTED_FUNC_NAMES_CALL_TEST = """
def __init__(test):
test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ast

from RestrictedPython import RestrictingNodeTransformer

import ast


def test_RestrictingNodeTransformer__generic_visit__1():
"""It log an error if there is an unknown ast node visited."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_exec

from ..helper import restricted_exec
from tests.helper import restricted_exec


GLOBAL_EXAMPLE = """
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import types

from RestrictedPython.Guards import guarded_iter_unpack_sequence
from tests.helper import restricted_exec

from ..helper import restricted_exec
import types


ITERATORS = """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_exec

from ..helper import restricted_exec
from tests.helper import restricted_exec


lambda_err_msg = 'Line 1: "_bad" is an invalid variable ' \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..helper import restricted_exec
from tests.helper import restricted_exec


WHILE = """\
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_exec

from ..helper import restricted_exec
from tests.helper import restricted_exec


BAD_NAME_STARTING_WITH_UNDERSCORE = """\
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from operator import getitem

from ..helper import restricted_eval
from tests.helper import restricted_eval


def test_slice():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..helper import restricted_exec
from tests.helper import restricted_exec


SIMPLE_SUBSCRIPTS = """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from RestrictedPython import compile_restricted_exec

from ..helper import restricted_exec
from tests.helper import restricted_exec


TRY_EXCEPT = """
Expand Down
Loading

0 comments on commit 8100312

Please sign in to comment.