Repository: zopefoundation/RestrictedPython (language: python)

Issue:
RestrictedPython.tests package no longer installed ?
## BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

I thought that the standard with zope packages was to include tests in the package, but the current versions of `RestrictedPython` no longer install the tests. With version `3.6.0`, `RestrictedPython.tests` was also installed, it's not the case with `5.1`. At that time, in the repository, the tests were located in [`src/RestrictedPython/tests`](https://github.com/zopefoundation/RestrictedPython/tree/3.6.0/src/RestrictedPython/tests), nowadays they are in [`tests`](https://github.com/zopefoundation/RestrictedPython/tree/5.2/tests) and they are not installed.

Is my understanding correct that it's expected to install the tests and  that they are now accidentally not installed because the tests were gradually moved from `src/RestrictedPython/tests` to `tests` in the making of version 4 ? In https://github.com/zopefoundation/zope.testrunner/issues/136#issuecomment-1159552141 @d-maurer gave a few arguments in favor of installing the tests. For reference, my use case is in an application applying some monkey patches to `RestrictedPython` and we run the original tests after applying the monkey patches to make sure the monkey patches do not break existing functionality.

### What I did:

I updated a Zope application that was using `RestrictedPython` version 3.6.0 to version 5.1

<!-- Enter a reproducible description, including preconditions. -->
```
pip install RestrictedPython==5.1
python -c 'import RestrictedPython.tests' 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'RestrictedPython.tests
```

### What I expect to happen:

I expected the package `RestrictedPython.tests` to be installed, it was installed with version 3.6.0

### What actually happened:

The package `RestrictedPython.tests` was not installed.

### What version of Python and Zope/Addons I am using:

<!-- Enter Operating system, Python and Zope versions you are using -->



Discussion / hints:
Jérome Perrin wrote at 2022-8-23 06:38 -0700:
>I thought that the standard with zope packages was to include tests in the package, but the current versions of `RestrictedPython` no longer install the tests. With version `3.6.0`, `RestrictedPython.tests` was also installed, it's not the case with `5.1`. At that time, in the repository, the tests were located in [`src/RestrictedPython/tests`](https://github.com/zopefoundation/RestrictedPython/tree/3.6.0/src/RestrictedPython/tests), nowadays they are in [`tests`](https://github.com/zopefoundation/RestrictedPython/tree/5.2/tests) and they are not installed.

I do not know why the tests have been moved.

A potential cause could be: `RestrictedPython` is one of the few
`zopefoundation` projects designed for `pytest` (rather than
`zope.testrunner`) as test runner.
`zope.testrunner` likes when the tests are part of the installed tree
(it makes the command significantly simpler).
Not installing them might have been a way to reduce the risk to
run the tests with the wrong test runner.

Recently, (some) `pytest` fans massively argumented against installing
the tests. Maybe, someone acted on those arguments.


Fix patch:
diff --git a/.meta.toml b/.meta.toml
index 81c8906..2b7a7f4 100644
--- a/.meta.toml
+++ b/.meta.toml
@@ -29,7 +29,7 @@ testenv-setenv = [
 testenv-commands = [
     "python -V",
     "pip list",
-    "pytest --cov=src --cov=tests --cov-report= {posargs}",
+    "pytest --cov=src --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=tests --cov-report= {posargs}"
+coverage-command = "pytest --cov=src --cov-report= {posargs}"
 coverage-setenv = [
     "COVERAGE_FILE=.coverage",
     ]
@@ -64,7 +64,6 @@ additional-rules = [
     "recursive-include docs *.ast",
     "recursive-include docs *.bat",
     "recursive-include docs *.jpg",
-    "recursive-include tests *.py",
     ]
 
 [check-manifest]
diff --git a/MANIFEST.in b/MANIFEST.in
index a1bb705..0d8944f 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -15,4 +15,3 @@ recursive-include src *.py
 recursive-include docs *.ast
 recursive-include docs *.bat
 recursive-include docs *.jpg
-recursive-include tests *.py
diff --git a/tox.ini b/tox.ini
index 9862d52..315cb6f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -29,7 +29,7 @@ setenv =
 commands =
     python -V
     pip list
-    pytest --cov=src --cov=tests --cov-report= {posargs}
+    pytest --cov=src --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=tests --cov-report= {posargs}
+    pytest --cov=src --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


Test patch:
diff --git a/tests/__init__.py b/src/RestrictedPython/tests/__init__.py
similarity index 100%
rename from tests/__init__.py
rename to src/RestrictedPython/tests/__init__.py
diff --git a/tests/builtins/test_limits.py b/src/RestrictedPython/tests/builtins/test_limits.py
similarity index 100%
rename from tests/builtins/test_limits.py
rename to src/RestrictedPython/tests/builtins/test_limits.py
index 8661960..1481946 100644
--- a/tests/builtins/test_limits.py
+++ b/src/RestrictedPython/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/tests/builtins/test_utilities.py b/src/RestrictedPython/tests/builtins/test_utilities.py
similarity index 100%
rename from tests/builtins/test_utilities.py
rename to src/RestrictedPython/tests/builtins/test_utilities.py
diff --git a/tests/helper.py b/src/RestrictedPython/tests/helper.py
similarity index 99%
rename from tests/helper.py
rename to src/RestrictedPython/tests/helper.py
index 25cf3bd..46efe2b 100644
--- a/tests/helper.py
+++ b/src/RestrictedPython/tests/helper.py
@@ -1,8 +1,7 @@
+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/tests/test_Guards.py b/src/RestrictedPython/tests/test_Guards.py
similarity index 98%
rename from tests/test_Guards.py
rename to src/RestrictedPython/tests/test_Guards.py
index 6fbf2ae..01ec228 100644
--- a/tests/test_Guards.py
+++ b/src/RestrictedPython/tests/test_Guards.py
@@ -1,12 +1,13 @@
+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
 
-import pytest
+from .helper import restricted_eval
+from .helper import restricted_exec
 
 
 def _write_(x):
diff --git a/tests/test_NamedExpr.py b/src/RestrictedPython/tests/test_NamedExpr.py
similarity index 99%
rename from tests/test_NamedExpr.py
rename to src/RestrictedPython/tests/test_NamedExpr.py
index be064e3..308d0dd 100644
--- a/tests/test_NamedExpr.py
+++ b/src/RestrictedPython/tests/test_NamedExpr.py
@@ -3,11 +3,12 @@
 
 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/tests/test_Utilities.py b/src/RestrictedPython/tests/test_Utilities.py
similarity index 100%
rename from tests/test_Utilities.py
rename to src/RestrictedPython/tests/test_Utilities.py
diff --git a/tests/test_compile.py b/src/RestrictedPython/tests/test_compile.py
similarity index 99%
rename from tests/test_compile.py
rename to src/RestrictedPython/tests/test_compile.py
index 4ef3869..7d67381 100644
--- a/tests/test_compile.py
+++ b/src/RestrictedPython/tests/test_compile.py
@@ -1,15 +1,17 @@
+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
 
-import platform
-import pytest
-import types
+from .helper import restricted_eval
 
 
 def test_compile__compile_restricted_invalid_code_input():
diff --git a/tests/test_compile_restricted_function.py b/src/RestrictedPython/tests/test_compile_restricted_function.py
similarity index 99%
rename from tests/test_compile_restricted_function.py
rename to src/RestrictedPython/tests/test_compile_restricted_function.py
index 5c81f86..8d9de6b 100644
--- a/tests/test_compile_restricted_function.py
+++ b/src/RestrictedPython/tests/test_compile_restricted_function.py
@@ -1,9 +1,10 @@
-from RestrictedPython import compile_restricted_function
+from types import FunctionType
+
 from RestrictedPython import PrintCollector
+from RestrictedPython import compile_restricted_function
 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/tests/test_eval.py b/src/RestrictedPython/tests/test_eval.py
similarity index 100%
rename from tests/test_eval.py
rename to src/RestrictedPython/tests/test_eval.py
index d1acf10..1225928 100644
--- a/tests/test_eval.py
+++ b/src/RestrictedPython/tests/test_eval.py
@@ -1,7 +1,7 @@
-from RestrictedPython.Eval import RestrictionCapableEval
-
 import pytest
 
+from RestrictedPython.Eval import RestrictionCapableEval
+
 
 exp = """
     {'a':[m.pop()]}['a'] \
diff --git a/tests/test_imports.py b/src/RestrictedPython/tests/test_imports.py
similarity index 97%
rename from tests/test_imports.py
rename to src/RestrictedPython/tests/test_imports.py
index 79f86d3..81ca056 100644
--- a/tests/test_imports.py
+++ b/src/RestrictedPython/tests/test_imports.py
@@ -2,11 +2,12 @@
 Tests about imports
 """
 
+import pytest
+
 from RestrictedPython import compile_restricted_exec
 from RestrictedPython import safe_builtins
-from tests.helper import restricted_exec
 
-import pytest
+from .helper import restricted_exec
 
 
 OS_IMPORT_EXAMPLE = """
diff --git a/tests/test_iterating_over_dict_items.py b/src/RestrictedPython/tests/test_iterating_over_dict_items.py
similarity index 100%
rename from tests/test_iterating_over_dict_items.py
rename to src/RestrictedPython/tests/test_iterating_over_dict_items.py
index b45d6d0..7157bab 100644
--- a/tests/test_iterating_over_dict_items.py
+++ b/src/RestrictedPython/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/tests/test_print_function.py b/src/RestrictedPython/tests/test_print_function.py
similarity index 99%
rename from tests/test_print_function.py
rename to src/RestrictedPython/tests/test_print_function.py
index d29fa18..f8e9282 100644
--- a/tests/test_print_function.py
+++ b/src/RestrictedPython/tests/test_print_function.py
@@ -1,6 +1,5 @@
-from RestrictedPython.PrintCollector import PrintCollector
-
 import RestrictedPython
+from RestrictedPython.PrintCollector import PrintCollector
 
 
 compiler = RestrictedPython.compile.compile_restricted_exec
diff --git a/src/RestrictedPython/tests/transformer/__init__.py b/src/RestrictedPython/tests/transformer/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/RestrictedPython/tests/transformer/operators/__init__.py b/src/RestrictedPython/tests/transformer/operators/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/transformer/operators/test_arithmetic_operators.py b/src/RestrictedPython/tests/transformer/operators/test_arithmetic_operators.py
similarity index 94%
rename from tests/transformer/operators/test_arithmetic_operators.py
rename to src/RestrictedPython/tests/transformer/operators/test_arithmetic_operators.py
index 209eb50..99197ec 100644
--- a/tests/transformer/operators/test_arithmetic_operators.py
+++ b/src/RestrictedPython/tests/transformer/operators/test_arithmetic_operators.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_eval
-from tests.helper import restricted_eval
+
+from ...helper import restricted_eval
 
 
 # Arithmetic Operators
diff --git a/tests/transformer/operators/test_bit_wise_operators.py b/src/RestrictedPython/tests/transformer/operators/test_bit_wise_operators.py
similarity index 90%
rename from tests/transformer/operators/test_bit_wise_operators.py
rename to src/RestrictedPython/tests/transformer/operators/test_bit_wise_operators.py
index 839c41f..281f1c9 100644
--- a/tests/transformer/operators/test_bit_wise_operators.py
+++ b/src/RestrictedPython/tests/transformer/operators/test_bit_wise_operators.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_eval
+from ...helper import restricted_eval
 
 
 def test_BitAnd():
diff --git a/tests/transformer/operators/test_bool_operators.py b/src/RestrictedPython/tests/transformer/operators/test_bool_operators.py
similarity index 83%
rename from tests/transformer/operators/test_bool_operators.py
rename to src/RestrictedPython/tests/transformer/operators/test_bool_operators.py
index 9bb8625..aa41f5b 100644
--- a/tests/transformer/operators/test_bool_operators.py
+++ b/src/RestrictedPython/tests/transformer/operators/test_bool_operators.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_eval
+from ...helper import restricted_eval
 
 
 def test_Or():
diff --git a/tests/transformer/operators/test_comparison_operators.py b/src/RestrictedPython/tests/transformer/operators/test_comparison_operators.py
similarity index 89%
rename from tests/transformer/operators/test_comparison_operators.py
rename to src/RestrictedPython/tests/transformer/operators/test_comparison_operators.py
index 7aa3e9a..8d8dc5e 100644
--- a/tests/transformer/operators/test_comparison_operators.py
+++ b/src/RestrictedPython/tests/transformer/operators/test_comparison_operators.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_eval
+from ...helper import restricted_eval
 
 
 def test_Eq():
diff --git a/tests/transformer/operators/test_identity_operators.py b/src/RestrictedPython/tests/transformer/operators/test_identity_operators.py
similarity index 77%
rename from tests/transformer/operators/test_identity_operators.py
rename to src/RestrictedPython/tests/transformer/operators/test_identity_operators.py
index ee9e9ca..1707e73 100644
--- a/tests/transformer/operators/test_identity_operators.py
+++ b/src/RestrictedPython/tests/transformer/operators/test_identity_operators.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_eval
+from ...helper import restricted_eval
 
 
 def test_Is():
diff --git a/tests/transformer/operators/test_logical_operators.py b/src/RestrictedPython/tests/transformer/operators/test_logical_operators.py
similarity index 78%
rename from tests/transformer/operators/test_logical_operators.py
rename to src/RestrictedPython/tests/transformer/operators/test_logical_operators.py
index b4c585f..5bc26d0 100644
--- a/tests/transformer/operators/test_logical_operators.py
+++ b/src/RestrictedPython/tests/transformer/operators/test_logical_operators.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_eval
+from ...helper import restricted_eval
 
 
 def test_In():
diff --git a/tests/transformer/operators/test_unary_operators.py b/src/RestrictedPython/tests/transformer/operators/test_unary_operators.py
similarity index 77%
rename from tests/transformer/operators/test_unary_operators.py
rename to src/RestrictedPython/tests/transformer/operators/test_unary_operators.py
index 71d5492..83c585f 100644
--- a/tests/transformer/operators/test_unary_operators.py
+++ b/src/RestrictedPython/tests/transformer/operators/test_unary_operators.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_eval
+from ...helper import restricted_eval
 
 
 def test_UAdd():
diff --git a/tests/transformer/test_assert.py b/src/RestrictedPython/tests/transformer/test_assert.py
similarity index 75%
rename from tests/transformer/test_assert.py
rename to src/RestrictedPython/tests/transformer/test_assert.py
index 984cb89..b747402 100644
--- a/tests/transformer/test_assert.py
+++ b/src/RestrictedPython/tests/transformer/test_assert.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_exec
+from ..helper import restricted_exec
 
 
 def test_RestrictingNodeTransformer__visit_Assert__1():
diff --git a/tests/transformer/test_assign.py b/src/RestrictedPython/tests/transformer/test_assign.py
similarity index 96%
rename from tests/transformer/test_assign.py
rename to src/RestrictedPython/tests/transformer/test_assign.py
index c72fb37..7ef9f32 100644
--- a/tests/transformer/test_assign.py
+++ b/src/RestrictedPython/tests/transformer/test_assign.py
@@ -1,5 +1,6 @@
 from RestrictedPython.Guards import guarded_unpack_sequence
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 def test_RestrictingNodeTransformer__visit_Assign__1(mocker):
diff --git a/tests/transformer/test_async.py b/src/RestrictedPython/tests/transformer/test_async.py
similarity index 100%
rename from tests/transformer/test_async.py
rename to src/RestrictedPython/tests/transformer/test_async.py
diff --git a/tests/transformer/test_attribute.py b/src/RestrictedPython/tests/transformer/test_attribute.py
similarity index 98%
rename from tests/transformer/test_attribute.py
rename to src/RestrictedPython/tests/transformer/test_attribute.py
index 1a6d239..5ca1432 100644
--- a/tests/transformer/test_attribute.py
+++ b/src/RestrictedPython/tests/transformer/test_attribute.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_exec
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 BAD_ATTR_UNDERSCORE = """\
diff --git a/tests/transformer/test_augassign.py b/src/RestrictedPython/tests/transformer/test_augassign.py
similarity index 97%
rename from tests/transformer/test_augassign.py
rename to src/RestrictedPython/tests/transformer/test_augassign.py
index 3b78498..eb84144 100644
--- a/tests/transformer/test_augassign.py
+++ b/src/RestrictedPython/tests/transformer/test_augassign.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_exec
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 def test_RestrictingNodeTransformer__visit_AugAssign__1(
diff --git a/tests/transformer/test_base_types.py b/src/RestrictedPython/tests/transformer/test_base_types.py
similarity index 93%
rename from tests/transformer/test_base_types.py
rename to src/RestrictedPython/tests/transformer/test_base_types.py
index a815f0f..dcdcd88 100644
--- a/tests/transformer/test_base_types.py
+++ b/src/RestrictedPython/tests/transformer/test_base_types.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_exec
-from tests.helper import restricted_eval
+
+from ..helper import restricted_eval
 
 
 def test_Num():
diff --git a/tests/transformer/test_breakpoint.py b/src/RestrictedPython/tests/transformer/test_breakpoint.py
similarity index 100%
rename from tests/transformer/test_breakpoint.py
rename to src/RestrictedPython/tests/transformer/test_breakpoint.py
diff --git a/tests/transformer/test_call.py b/src/RestrictedPython/tests/transformer/test_call.py
similarity index 98%
rename from tests/transformer/test_call.py
rename to src/RestrictedPython/tests/transformer/test_call.py
index a44cf0b..059bbf1 100644
--- a/tests/transformer/test_call.py
+++ b/src/RestrictedPython/tests/transformer/test_call.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_exec
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 def test_RestrictingNodeTransformer__visit_Call__1():
diff --git a/tests/transformer/test_classdef.py b/src/RestrictedPython/tests/transformer/test_classdef.py
similarity index 99%
rename from tests/transformer/test_classdef.py
rename to src/RestrictedPython/tests/transformer/test_classdef.py
index 8b370ab..e5e1e83 100644
--- a/tests/transformer/test_classdef.py
+++ b/src/RestrictedPython/tests/transformer/test_classdef.py
@@ -1,6 +1,7 @@
 from RestrictedPython import compile_restricted_exec
 from RestrictedPython.Guards import safe_builtins
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 GOOD_CLASS = '''
diff --git a/tests/transformer/test_comparators.py b/src/RestrictedPython/tests/transformer/test_comparators.py
similarity index 98%
rename from tests/transformer/test_comparators.py
rename to src/RestrictedPython/tests/transformer/test_comparators.py
index 26a00c7..4e13fbb 100644
--- a/tests/transformer/test_comparators.py
+++ b/src/RestrictedPython/tests/transformer/test_comparators.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_eval
+from ..helper import restricted_eval
 
 
 def test_RestrictingNodeTransformer__visit_Eq__1():
diff --git a/tests/transformer/test_conditional.py b/src/RestrictedPython/tests/transformer/test_conditional.py
similarity index 95%
rename from tests/transformer/test_conditional.py
rename to src/RestrictedPython/tests/transformer/test_conditional.py
index 6f222a4..ad56e13 100644
--- a/tests/transformer/test_conditional.py
+++ b/src/RestrictedPython/tests/transformer/test_conditional.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_exec
+from ..helper import restricted_exec
 
 
 def test_RestrictingNodeTransformer__test_ternary_if(
diff --git a/tests/transformer/test_dict_comprehension.py b/src/RestrictedPython/tests/transformer/test_dict_comprehension.py
similarity index 96%
rename from tests/transformer/test_dict_comprehension.py
rename to src/RestrictedPython/tests/transformer/test_dict_comprehension.py
index 17b8c45..a414511 100644
--- a/tests/transformer/test_dict_comprehension.py
+++ b/src/RestrictedPython/tests/transformer/test_dict_comprehension.py
@@ -1,5 +1,6 @@
 from RestrictedPython._compat import IS_PY38_OR_GREATER
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 DICT_COMPREHENSION_WITH_ATTRS = """
diff --git a/tests/transformer/test_eval_exec.py b/src/RestrictedPython/tests/transformer/test_eval_exec.py
similarity index 100%
rename from tests/transformer/test_eval_exec.py
rename to src/RestrictedPython/tests/transformer/test_eval_exec.py
diff --git a/tests/transformer/test_fstring.py b/src/RestrictedPython/tests/transformer/test_fstring.py
similarity index 100%
rename from tests/transformer/test_fstring.py
rename to src/RestrictedPython/tests/transformer/test_fstring.py
index 981026e..68b1743 100644
--- a/tests/transformer/test_fstring.py
+++ b/src/RestrictedPython/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/tests/transformer/test_functiondef.py b/src/RestrictedPython/tests/transformer/test_functiondef.py
similarity index 99%
rename from tests/transformer/test_functiondef.py
rename to src/RestrictedPython/tests/transformer/test_functiondef.py
index 17730f3..654b11d 100644
--- a/tests/transformer/test_functiondef.py
+++ b/src/RestrictedPython/tests/transformer/test_functiondef.py
@@ -35,7 +35,6 @@ def test_RestrictingNodeTransformer__visit_FunctionDef__7():
     assert result.errors == (functiondef_err_msg,)
 
 
-
 BLACKLISTED_FUNC_NAMES_CALL_TEST = """
 def __init__(test):
     test
diff --git a/tests/transformer/test_generic.py b/src/RestrictedPython/tests/transformer/test_generic.py
similarity index 100%
rename from tests/transformer/test_generic.py
rename to src/RestrictedPython/tests/transformer/test_generic.py
index 8ca41ce..b0b748f 100644
--- a/tests/transformer/test_generic.py
+++ b/src/RestrictedPython/tests/transformer/test_generic.py
@@ -1,7 +1,7 @@
-from RestrictedPython import RestrictingNodeTransformer
-
 import ast
 
+from RestrictedPython import RestrictingNodeTransformer
+
 
 def test_RestrictingNodeTransformer__generic_visit__1():
     """It log an error if there is an unknown ast node visited."""
diff --git a/tests/transformer/test_global_local.py b/src/RestrictedPython/tests/transformer/test_global_local.py
similarity index 94%
rename from tests/transformer/test_global_local.py
rename to src/RestrictedPython/tests/transformer/test_global_local.py
index 3af01b4..dd4642a 100644
--- a/tests/transformer/test_global_local.py
+++ b/src/RestrictedPython/tests/transformer/test_global_local.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_exec
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 GLOBAL_EXAMPLE = """
diff --git a/tests/transformer/test_import.py b/src/RestrictedPython/tests/transformer/test_import.py
similarity index 100%
rename from tests/transformer/test_import.py
rename to src/RestrictedPython/tests/transformer/test_import.py
diff --git a/tests/transformer/test_iterator.py b/src/RestrictedPython/tests/transformer/test_iterator.py
similarity index 98%
rename from tests/transformer/test_iterator.py
rename to src/RestrictedPython/tests/transformer/test_iterator.py
index bd593ab..9e53ad0 100644
--- a/tests/transformer/test_iterator.py
+++ b/src/RestrictedPython/tests/transformer/test_iterator.py
@@ -1,7 +1,8 @@
+import types
+
 from RestrictedPython.Guards import guarded_iter_unpack_sequence
-from tests.helper import restricted_exec
 
-import types
+from ..helper import restricted_exec
 
 
 ITERATORS = """
diff --git a/tests/transformer/test_lambda.py b/src/RestrictedPython/tests/transformer/test_lambda.py
similarity index 97%
rename from tests/transformer/test_lambda.py
rename to src/RestrictedPython/tests/transformer/test_lambda.py
index 2bf1f2e..b9428d5 100644
--- a/tests/transformer/test_lambda.py
+++ b/src/RestrictedPython/tests/transformer/test_lambda.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_exec
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 lambda_err_msg = 'Line 1: "_bad" is an invalid variable ' \
diff --git a/tests/transformer/test_loop.py b/src/RestrictedPython/tests/transformer/test_loop.py
similarity index 94%
rename from tests/transformer/test_loop.py
rename to src/RestrictedPython/tests/transformer/test_loop.py
index 971bff2..a7777dd 100644
--- a/tests/transformer/test_loop.py
+++ b/src/RestrictedPython/tests/transformer/test_loop.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_exec
+from ..helper import restricted_exec
 
 
 WHILE = """\
diff --git a/tests/transformer/test_name.py b/src/RestrictedPython/tests/transformer/test_name.py
similarity index 99%
rename from tests/transformer/test_name.py
rename to src/RestrictedPython/tests/transformer/test_name.py
index e37d2d7..493dd4c 100644
--- a/tests/transformer/test_name.py
+++ b/src/RestrictedPython/tests/transformer/test_name.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_exec
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 BAD_NAME_STARTING_WITH_UNDERSCORE = """\
diff --git a/tests/transformer/test_slice.py b/src/RestrictedPython/tests/transformer/test_slice.py
similarity index 94%
rename from tests/transformer/test_slice.py
rename to src/RestrictedPython/tests/transformer/test_slice.py
index f2eff38..b2220d2 100644
--- a/tests/transformer/test_slice.py
+++ b/src/RestrictedPython/tests/transformer/test_slice.py
@@ -1,5 +1,6 @@
 from operator import getitem
-from tests.helper import restricted_eval
+
+from ..helper import restricted_eval
 
 
 def test_slice():
diff --git a/tests/transformer/test_subscript.py b/src/RestrictedPython/tests/transformer/test_subscript.py
similarity index 99%
rename from tests/transformer/test_subscript.py
rename to src/RestrictedPython/tests/transformer/test_subscript.py
index f774e1e..b42edee 100644
--- a/tests/transformer/test_subscript.py
+++ b/src/RestrictedPython/tests/transformer/test_subscript.py
@@ -1,4 +1,4 @@
-from tests.helper import restricted_exec
+from ..helper import restricted_exec
 
 
 SIMPLE_SUBSCRIPTS = """
diff --git a/tests/transformer/test_try.py b/src/RestrictedPython/tests/transformer/test_try.py
similarity index 98%
rename from tests/transformer/test_try.py
rename to src/RestrictedPython/tests/transformer/test_try.py
index 4abe400..9a4dae6 100644
--- a/tests/transformer/test_try.py
+++ b/src/RestrictedPython/tests/transformer/test_try.py
@@ -1,5 +1,6 @@
 from RestrictedPython import compile_restricted_exec
-from tests.helper import restricted_exec
+
+from ..helper import restricted_exec
 
 
 TRY_EXCEPT = """
diff --git a/tests/transformer/test_with_stmt.py b/src/RestrictedPython/tests/transformer/test_with_stmt.py
similarity index 98%
rename from tests/transformer/test_with_stmt.py
rename to src/RestrictedPython/tests/transformer/test_with_stmt.py
index 57e440f..7431729 100644
--- a/tests/transformer/test_with_stmt.py
+++ b/src/RestrictedPython/tests/transformer/test_with_stmt.py
@@ -1,8 +1,9 @@
+import contextlib
+
 from RestrictedPython import compile_restricted_exec
 from RestrictedPython.Guards import guarded_unpack_sequence
-from tests.helper import restricted_exec
 
-import contextlib
+from ..helper import restricted_exec
 
 
 WITH_STMT_WITH_UNPACK_SEQUENCE = """
diff --git a/tests/transformer/test_yield.py b/src/RestrictedPython/tests/transformer/test_yield.py
similarity index 98%
rename from tests/transformer/test_yield.py
rename to src/RestrictedPython/tests/transformer/test_yield.py
index 33fb631..a85e603 100644
--- a/tests/transformer/test_yield.py
+++ b/src/RestrictedPython/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)