diff --git a/.meta.toml b/.meta.toml index 2b7a7f4..81c8906 100644 --- a/.meta.toml +++ b/.meta.toml @@ -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 = [ "", @@ -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", ] @@ -64,6 +64,7 @@ additional-rules = [ "recursive-include docs *.ast", "recursive-include docs *.bat", "recursive-include docs *.jpg", + "recursive-include tests *.py", ] [check-manifest] diff --git a/CHANGES.rst b/CHANGES.rst index d30ed10..8203ff8 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,9 +17,6 @@ Features - Fix code to run on Python 3.11.0b3. -- Move ``tests`` directory into ``src``. - (`#232 `_) - 5.2 (2021-11-19) ---------------- diff --git a/MANIFEST.in b/MANIFEST.in index 0d8944f..a1bb705 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -15,3 +15,4 @@ recursive-include src *.py recursive-include docs *.ast recursive-include docs *.bat recursive-include docs *.jpg +recursive-include tests *.py diff --git a/src/RestrictedPython/tests/transformer/__init__.py b/src/RestrictedPython/tests/transformer/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/RestrictedPython/tests/transformer/operators/__init__.py b/src/RestrictedPython/tests/transformer/operators/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/RestrictedPython/tests/__init__.py b/tests/__init__.py similarity index 100% rename from src/RestrictedPython/tests/__init__.py rename to tests/__init__.py diff --git a/src/RestrictedPython/tests/builtins/test_limits.py b/tests/builtins/test_limits.py similarity index 100% rename from src/RestrictedPython/tests/builtins/test_limits.py rename to tests/builtins/test_limits.py index 1481946..8661960 100644 --- a/src/RestrictedPython/tests/builtins/test_limits.py +++ b/tests/builtins/test_limits.py @@ -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) diff --git a/src/RestrictedPython/tests/builtins/test_utilities.py b/tests/builtins/test_utilities.py similarity index 100% rename from src/RestrictedPython/tests/builtins/test_utilities.py rename to tests/builtins/test_utilities.py diff --git a/src/RestrictedPython/tests/helper.py b/tests/helper.py similarity index 99% rename from src/RestrictedPython/tests/helper.py rename to tests/helper.py index 46efe2b..25cf3bd 100644 --- a/src/RestrictedPython/tests/helper.py +++ b/tests/helper.py @@ -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.""" diff --git a/src/RestrictedPython/tests/test_Guards.py b/tests/test_Guards.py similarity index 98% rename from src/RestrictedPython/tests/test_Guards.py rename to tests/test_Guards.py index 01ec228..6fbf2ae 100644 --- a/src/RestrictedPython/tests/test_Guards.py +++ b/tests/test_Guards.py @@ -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): diff --git a/src/RestrictedPython/tests/test_NamedExpr.py b/tests/test_NamedExpr.py similarity index 99% rename from src/RestrictedPython/tests/test_NamedExpr.py rename to tests/test_NamedExpr.py index 308d0dd..be064e3 100644 --- a/src/RestrictedPython/tests/test_NamedExpr.py +++ b/tests/test_NamedExpr.py @@ -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+") diff --git a/src/RestrictedPython/tests/test_Utilities.py b/tests/test_Utilities.py similarity index 100% rename from src/RestrictedPython/tests/test_Utilities.py rename to tests/test_Utilities.py diff --git a/src/RestrictedPython/tests/test_compile.py b/tests/test_compile.py similarity index 99% rename from src/RestrictedPython/tests/test_compile.py rename to tests/test_compile.py index 7d67381..4ef3869 100644 --- a/src/RestrictedPython/tests/test_compile.py +++ b/tests/test_compile.py @@ -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(): diff --git a/src/RestrictedPython/tests/test_compile_restricted_function.py b/tests/test_compile_restricted_function.py similarity index 99% rename from src/RestrictedPython/tests/test_compile_restricted_function.py rename to tests/test_compile_restricted_function.py index 8d9de6b..5c81f86 100644 --- a/src/RestrictedPython/tests/test_compile_restricted_function.py +++ b/tests/test_compile_restricted_function.py @@ -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(): diff --git a/src/RestrictedPython/tests/test_eval.py b/tests/test_eval.py similarity index 100% rename from src/RestrictedPython/tests/test_eval.py rename to tests/test_eval.py index 1225928..d1acf10 100644 --- a/src/RestrictedPython/tests/test_eval.py +++ b/tests/test_eval.py @@ -1,7 +1,7 @@ -import pytest - from RestrictedPython.Eval import RestrictionCapableEval +import pytest + exp = """ {'a':[m.pop()]}['a'] \ diff --git a/src/RestrictedPython/tests/test_imports.py b/tests/test_imports.py similarity index 97% rename from src/RestrictedPython/tests/test_imports.py rename to tests/test_imports.py index 81ca056..79f86d3 100644 --- a/src/RestrictedPython/tests/test_imports.py +++ b/tests/test_imports.py @@ -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 = """ diff --git a/src/RestrictedPython/tests/test_iterating_over_dict_items.py b/tests/test_iterating_over_dict_items.py similarity index 100% rename from src/RestrictedPython/tests/test_iterating_over_dict_items.py rename to tests/test_iterating_over_dict_items.py index 7157bab..b45d6d0 100644 --- a/src/RestrictedPython/tests/test_iterating_over_dict_items.py +++ b/tests/test_iterating_over_dict_items.py @@ -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'} diff --git a/src/RestrictedPython/tests/test_print_function.py b/tests/test_print_function.py similarity index 99% rename from src/RestrictedPython/tests/test_print_function.py rename to tests/test_print_function.py index f8e9282..d29fa18 100644 --- a/src/RestrictedPython/tests/test_print_function.py +++ b/tests/test_print_function.py @@ -1,6 +1,7 @@ -import RestrictedPython from RestrictedPython.PrintCollector import PrintCollector +import RestrictedPython + compiler = RestrictedPython.compile.compile_restricted_exec diff --git a/src/RestrictedPython/tests/transformer/operators/test_arithmetic_operators.py b/tests/transformer/operators/test_arithmetic_operators.py similarity index 94% rename from src/RestrictedPython/tests/transformer/operators/test_arithmetic_operators.py rename to tests/transformer/operators/test_arithmetic_operators.py index 99197ec..209eb50 100644 --- a/src/RestrictedPython/tests/transformer/operators/test_arithmetic_operators.py +++ b/tests/transformer/operators/test_arithmetic_operators.py @@ -1,6 +1,5 @@ from RestrictedPython import compile_restricted_eval - -from ...helper import restricted_eval +from tests.helper import restricted_eval # Arithmetic Operators diff --git a/src/RestrictedPython/tests/transformer/operators/test_bit_wise_operators.py b/tests/transformer/operators/test_bit_wise_operators.py similarity index 90% rename from src/RestrictedPython/tests/transformer/operators/test_bit_wise_operators.py rename to tests/transformer/operators/test_bit_wise_operators.py index 281f1c9..839c41f 100644 --- a/src/RestrictedPython/tests/transformer/operators/test_bit_wise_operators.py +++ b/tests/transformer/operators/test_bit_wise_operators.py @@ -1,4 +1,4 @@ -from ...helper import restricted_eval +from tests.helper import restricted_eval def test_BitAnd(): diff --git a/src/RestrictedPython/tests/transformer/operators/test_bool_operators.py b/tests/transformer/operators/test_bool_operators.py similarity index 83% rename from src/RestrictedPython/tests/transformer/operators/test_bool_operators.py rename to tests/transformer/operators/test_bool_operators.py index aa41f5b..9bb8625 100644 --- a/src/RestrictedPython/tests/transformer/operators/test_bool_operators.py +++ b/tests/transformer/operators/test_bool_operators.py @@ -1,4 +1,4 @@ -from ...helper import restricted_eval +from tests.helper import restricted_eval def test_Or(): diff --git a/src/RestrictedPython/tests/transformer/operators/test_comparison_operators.py b/tests/transformer/operators/test_comparison_operators.py similarity index 89% rename from src/RestrictedPython/tests/transformer/operators/test_comparison_operators.py rename to tests/transformer/operators/test_comparison_operators.py index 8d8dc5e..7aa3e9a 100644 --- a/src/RestrictedPython/tests/transformer/operators/test_comparison_operators.py +++ b/tests/transformer/operators/test_comparison_operators.py @@ -1,4 +1,4 @@ -from ...helper import restricted_eval +from tests.helper import restricted_eval def test_Eq(): diff --git a/src/RestrictedPython/tests/transformer/operators/test_identity_operators.py b/tests/transformer/operators/test_identity_operators.py similarity index 77% rename from src/RestrictedPython/tests/transformer/operators/test_identity_operators.py rename to tests/transformer/operators/test_identity_operators.py index 1707e73..ee9e9ca 100644 --- a/src/RestrictedPython/tests/transformer/operators/test_identity_operators.py +++ b/tests/transformer/operators/test_identity_operators.py @@ -1,4 +1,4 @@ -from ...helper import restricted_eval +from tests.helper import restricted_eval def test_Is(): diff --git a/src/RestrictedPython/tests/transformer/operators/test_logical_operators.py b/tests/transformer/operators/test_logical_operators.py similarity index 78% rename from src/RestrictedPython/tests/transformer/operators/test_logical_operators.py rename to tests/transformer/operators/test_logical_operators.py index 5bc26d0..b4c585f 100644 --- a/src/RestrictedPython/tests/transformer/operators/test_logical_operators.py +++ b/tests/transformer/operators/test_logical_operators.py @@ -1,4 +1,4 @@ -from ...helper import restricted_eval +from tests.helper import restricted_eval def test_In(): diff --git a/src/RestrictedPython/tests/transformer/operators/test_unary_operators.py b/tests/transformer/operators/test_unary_operators.py similarity index 77% rename from src/RestrictedPython/tests/transformer/operators/test_unary_operators.py rename to tests/transformer/operators/test_unary_operators.py index 83c585f..71d5492 100644 --- a/src/RestrictedPython/tests/transformer/operators/test_unary_operators.py +++ b/tests/transformer/operators/test_unary_operators.py @@ -1,4 +1,4 @@ -from ...helper import restricted_eval +from tests.helper import restricted_eval def test_UAdd(): diff --git a/src/RestrictedPython/tests/transformer/test_assert.py b/tests/transformer/test_assert.py similarity index 75% rename from src/RestrictedPython/tests/transformer/test_assert.py rename to tests/transformer/test_assert.py index b747402..984cb89 100644 --- a/src/RestrictedPython/tests/transformer/test_assert.py +++ b/tests/transformer/test_assert.py @@ -1,4 +1,4 @@ -from ..helper import restricted_exec +from tests.helper import restricted_exec def test_RestrictingNodeTransformer__visit_Assert__1(): diff --git a/src/RestrictedPython/tests/transformer/test_assign.py b/tests/transformer/test_assign.py similarity index 96% rename from src/RestrictedPython/tests/transformer/test_assign.py rename to tests/transformer/test_assign.py index 7ef9f32..c72fb37 100644 --- a/src/RestrictedPython/tests/transformer/test_assign.py +++ b/tests/transformer/test_assign.py @@ -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): diff --git a/src/RestrictedPython/tests/transformer/test_async.py b/tests/transformer/test_async.py similarity index 100% rename from src/RestrictedPython/tests/transformer/test_async.py rename to tests/transformer/test_async.py diff --git a/src/RestrictedPython/tests/transformer/test_attribute.py b/tests/transformer/test_attribute.py similarity index 98% rename from src/RestrictedPython/tests/transformer/test_attribute.py rename to tests/transformer/test_attribute.py index 5ca1432..1a6d239 100644 --- a/src/RestrictedPython/tests/transformer/test_attribute.py +++ b/tests/transformer/test_attribute.py @@ -1,6 +1,5 @@ from RestrictedPython import compile_restricted_exec - -from ..helper import restricted_exec +from tests.helper import restricted_exec BAD_ATTR_UNDERSCORE = """\ diff --git a/src/RestrictedPython/tests/transformer/test_augassign.py b/tests/transformer/test_augassign.py similarity index 97% rename from src/RestrictedPython/tests/transformer/test_augassign.py rename to tests/transformer/test_augassign.py index eb84144..3b78498 100644 --- a/src/RestrictedPython/tests/transformer/test_augassign.py +++ b/tests/transformer/test_augassign.py @@ -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( diff --git a/src/RestrictedPython/tests/transformer/test_base_types.py b/tests/transformer/test_base_types.py similarity index 93% rename from src/RestrictedPython/tests/transformer/test_base_types.py rename to tests/transformer/test_base_types.py index dcdcd88..a815f0f 100644 --- a/src/RestrictedPython/tests/transformer/test_base_types.py +++ b/tests/transformer/test_base_types.py @@ -1,6 +1,5 @@ from RestrictedPython import compile_restricted_exec - -from ..helper import restricted_eval +from tests.helper import restricted_eval def test_Num(): diff --git a/src/RestrictedPython/tests/transformer/test_breakpoint.py b/tests/transformer/test_breakpoint.py similarity index 100% rename from src/RestrictedPython/tests/transformer/test_breakpoint.py rename to tests/transformer/test_breakpoint.py diff --git a/src/RestrictedPython/tests/transformer/test_call.py b/tests/transformer/test_call.py similarity index 98% rename from src/RestrictedPython/tests/transformer/test_call.py rename to tests/transformer/test_call.py index 059bbf1..a44cf0b 100644 --- a/src/RestrictedPython/tests/transformer/test_call.py +++ b/tests/transformer/test_call.py @@ -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(): diff --git a/src/RestrictedPython/tests/transformer/test_classdef.py b/tests/transformer/test_classdef.py similarity index 99% rename from src/RestrictedPython/tests/transformer/test_classdef.py rename to tests/transformer/test_classdef.py index e5e1e83..8b370ab 100644 --- a/src/RestrictedPython/tests/transformer/test_classdef.py +++ b/tests/transformer/test_classdef.py @@ -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 = ''' diff --git a/src/RestrictedPython/tests/transformer/test_comparators.py b/tests/transformer/test_comparators.py similarity index 98% rename from src/RestrictedPython/tests/transformer/test_comparators.py rename to tests/transformer/test_comparators.py index 4e13fbb..26a00c7 100644 --- a/src/RestrictedPython/tests/transformer/test_comparators.py +++ b/tests/transformer/test_comparators.py @@ -1,4 +1,4 @@ -from ..helper import restricted_eval +from tests.helper import restricted_eval def test_RestrictingNodeTransformer__visit_Eq__1(): diff --git a/src/RestrictedPython/tests/transformer/test_conditional.py b/tests/transformer/test_conditional.py similarity index 95% rename from src/RestrictedPython/tests/transformer/test_conditional.py rename to tests/transformer/test_conditional.py index ad56e13..6f222a4 100644 --- a/src/RestrictedPython/tests/transformer/test_conditional.py +++ b/tests/transformer/test_conditional.py @@ -1,4 +1,4 @@ -from ..helper import restricted_exec +from tests.helper import restricted_exec def test_RestrictingNodeTransformer__test_ternary_if( diff --git a/src/RestrictedPython/tests/transformer/test_dict_comprehension.py b/tests/transformer/test_dict_comprehension.py similarity index 96% rename from src/RestrictedPython/tests/transformer/test_dict_comprehension.py rename to tests/transformer/test_dict_comprehension.py index a414511..17b8c45 100644 --- a/src/RestrictedPython/tests/transformer/test_dict_comprehension.py +++ b/tests/transformer/test_dict_comprehension.py @@ -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 = """ diff --git a/src/RestrictedPython/tests/transformer/test_eval_exec.py b/tests/transformer/test_eval_exec.py similarity index 100% rename from src/RestrictedPython/tests/transformer/test_eval_exec.py rename to tests/transformer/test_eval_exec.py diff --git a/src/RestrictedPython/tests/transformer/test_fstring.py b/tests/transformer/test_fstring.py similarity index 100% rename from src/RestrictedPython/tests/transformer/test_fstring.py rename to tests/transformer/test_fstring.py index 68b1743..981026e 100644 --- a/src/RestrictedPython/tests/transformer/test_fstring.py +++ b/tests/transformer/test_fstring.py @@ -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.""" diff --git a/src/RestrictedPython/tests/transformer/test_functiondef.py b/tests/transformer/test_functiondef.py similarity index 99% rename from src/RestrictedPython/tests/transformer/test_functiondef.py rename to tests/transformer/test_functiondef.py index 654b11d..17730f3 100644 --- a/src/RestrictedPython/tests/transformer/test_functiondef.py +++ b/tests/transformer/test_functiondef.py @@ -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 diff --git a/src/RestrictedPython/tests/transformer/test_generic.py b/tests/transformer/test_generic.py similarity index 100% rename from src/RestrictedPython/tests/transformer/test_generic.py rename to tests/transformer/test_generic.py index b0b748f..8ca41ce 100644 --- a/src/RestrictedPython/tests/transformer/test_generic.py +++ b/tests/transformer/test_generic.py @@ -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.""" diff --git a/src/RestrictedPython/tests/transformer/test_global_local.py b/tests/transformer/test_global_local.py similarity index 94% rename from src/RestrictedPython/tests/transformer/test_global_local.py rename to tests/transformer/test_global_local.py index dd4642a..3af01b4 100644 --- a/src/RestrictedPython/tests/transformer/test_global_local.py +++ b/tests/transformer/test_global_local.py @@ -1,6 +1,5 @@ from RestrictedPython import compile_restricted_exec - -from ..helper import restricted_exec +from tests.helper import restricted_exec GLOBAL_EXAMPLE = """ diff --git a/src/RestrictedPython/tests/transformer/test_import.py b/tests/transformer/test_import.py similarity index 100% rename from src/RestrictedPython/tests/transformer/test_import.py rename to tests/transformer/test_import.py diff --git a/src/RestrictedPython/tests/transformer/test_iterator.py b/tests/transformer/test_iterator.py similarity index 98% rename from src/RestrictedPython/tests/transformer/test_iterator.py rename to tests/transformer/test_iterator.py index 9e53ad0..bd593ab 100644 --- a/src/RestrictedPython/tests/transformer/test_iterator.py +++ b/tests/transformer/test_iterator.py @@ -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 = """ diff --git a/src/RestrictedPython/tests/transformer/test_lambda.py b/tests/transformer/test_lambda.py similarity index 97% rename from src/RestrictedPython/tests/transformer/test_lambda.py rename to tests/transformer/test_lambda.py index b9428d5..2bf1f2e 100644 --- a/src/RestrictedPython/tests/transformer/test_lambda.py +++ b/tests/transformer/test_lambda.py @@ -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 ' \ diff --git a/src/RestrictedPython/tests/transformer/test_loop.py b/tests/transformer/test_loop.py similarity index 94% rename from src/RestrictedPython/tests/transformer/test_loop.py rename to tests/transformer/test_loop.py index a7777dd..971bff2 100644 --- a/src/RestrictedPython/tests/transformer/test_loop.py +++ b/tests/transformer/test_loop.py @@ -1,4 +1,4 @@ -from ..helper import restricted_exec +from tests.helper import restricted_exec WHILE = """\ diff --git a/src/RestrictedPython/tests/transformer/test_name.py b/tests/transformer/test_name.py similarity index 99% rename from src/RestrictedPython/tests/transformer/test_name.py rename to tests/transformer/test_name.py index 493dd4c..e37d2d7 100644 --- a/src/RestrictedPython/tests/transformer/test_name.py +++ b/tests/transformer/test_name.py @@ -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 = """\ diff --git a/src/RestrictedPython/tests/transformer/test_slice.py b/tests/transformer/test_slice.py similarity index 94% rename from src/RestrictedPython/tests/transformer/test_slice.py rename to tests/transformer/test_slice.py index b2220d2..f2eff38 100644 --- a/src/RestrictedPython/tests/transformer/test_slice.py +++ b/tests/transformer/test_slice.py @@ -1,6 +1,5 @@ from operator import getitem - -from ..helper import restricted_eval +from tests.helper import restricted_eval def test_slice(): diff --git a/src/RestrictedPython/tests/transformer/test_subscript.py b/tests/transformer/test_subscript.py similarity index 99% rename from src/RestrictedPython/tests/transformer/test_subscript.py rename to tests/transformer/test_subscript.py index b42edee..f774e1e 100644 --- a/src/RestrictedPython/tests/transformer/test_subscript.py +++ b/tests/transformer/test_subscript.py @@ -1,4 +1,4 @@ -from ..helper import restricted_exec +from tests.helper import restricted_exec SIMPLE_SUBSCRIPTS = """ diff --git a/src/RestrictedPython/tests/transformer/test_try.py b/tests/transformer/test_try.py similarity index 98% rename from src/RestrictedPython/tests/transformer/test_try.py rename to tests/transformer/test_try.py index 9a4dae6..4abe400 100644 --- a/src/RestrictedPython/tests/transformer/test_try.py +++ b/tests/transformer/test_try.py @@ -1,6 +1,5 @@ from RestrictedPython import compile_restricted_exec - -from ..helper import restricted_exec +from tests.helper import restricted_exec TRY_EXCEPT = """ diff --git a/src/RestrictedPython/tests/transformer/test_with_stmt.py b/tests/transformer/test_with_stmt.py similarity index 98% rename from src/RestrictedPython/tests/transformer/test_with_stmt.py rename to tests/transformer/test_with_stmt.py index 7431729..57e440f 100644 --- a/src/RestrictedPython/tests/transformer/test_with_stmt.py +++ b/tests/transformer/test_with_stmt.py @@ -1,9 +1,8 @@ -import contextlib - from RestrictedPython import compile_restricted_exec from RestrictedPython.Guards import guarded_unpack_sequence +from tests.helper import restricted_exec -from ..helper import restricted_exec +import contextlib WITH_STMT_WITH_UNPACK_SEQUENCE = """ diff --git a/src/RestrictedPython/tests/transformer/test_yield.py b/tests/transformer/test_yield.py similarity index 98% rename from src/RestrictedPython/tests/transformer/test_yield.py rename to tests/transformer/test_yield.py index a85e603..33fb631 100644 --- a/src/RestrictedPython/tests/transformer/test_yield.py +++ b/tests/transformer/test_yield.py @@ -34,7 +34,7 @@ def test_yield_from(): def my_external_generator(): my_list = [1, 2, 3, 4, 5] for elem in my_list: - yield elem + yield(elem) local = {} exec(result.code, {}, local) diff --git a/tox.ini b/tox.ini index 315cb6f..9862d52 100644 --- a/tox.ini +++ b/tox.ini @@ -29,7 +29,7 @@ setenv = commands = python -V pip list - pytest --cov=src --cov-report= {posargs} + pytest --cov=src --cov=tests --cov-report= {posargs} sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest extras = test @@ -98,7 +98,7 @@ setenv = COVERAGE_FILE=.coverage commands = mkdir -p {toxinidir}/parts/htmlcov - pytest --cov=src --cov-report= {posargs} + pytest --cov=src --cov=tests --cov-report= {posargs} coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest coverage html coverage report -m --fail-under=98.8