From cfa51788a682c4f09f5e17f9cb4e56a4469b79b3 Mon Sep 17 00:00:00 2001 From: GergelyKalmar Date: Sat, 20 Aug 2022 14:25:20 +0200 Subject: [PATCH 1/4] Ignore editable installation modules --- src/_pytest/config/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index b3173d7d736..d0f0402ba1f 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -836,7 +836,8 @@ def _iter_rewritable_modules(package_files: Iterable[str]) -> Iterator[str]: if is_simple_module: module_name, _ = os.path.splitext(fn) # we ignore "setup.py" at the root of the distribution - if module_name != "setup": + # as well as editable installation finder modules made by setuptools + if module_name != "setup" and not module_name.startswith('__editable__'): seen_some = True yield module_name elif is_package: From 07c0fac4b80d786b79ab378b7c8e6e1c07bda438 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 20 Aug 2022 12:31:42 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/config/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index d0f0402ba1f..d753a9054ab 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -837,7 +837,7 @@ def _iter_rewritable_modules(package_files: Iterable[str]) -> Iterator[str]: module_name, _ = os.path.splitext(fn) # we ignore "setup.py" at the root of the distribution # as well as editable installation finder modules made by setuptools - if module_name != "setup" and not module_name.startswith('__editable__'): + if module_name != "setup" and not module_name.startswith("__editable__"): seen_some = True yield module_name elif is_package: From 9d838a248c8acc85b8b32c509ee4ae3a96218970 Mon Sep 17 00:00:00 2001 From: GergelyKalmar Date: Fri, 26 Aug 2022 13:16:51 +0200 Subject: [PATCH 3/4] Add tests --- testing/test_config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/test_config.py b/testing/test_config.py index c2e3fe5bbcf..f5b6d7f9816 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -842,6 +842,9 @@ def test_confcutdir_check_isdir(self, pytester: Pytester) -> None: (["src/bar/__init__.py"], ["bar"]), (["src/bar/__init__.py", "setup.py"], ["bar"]), (["source/python/bar/__init__.py", "setup.py"], ["bar"]), + # editable installation finder modules + (["__editable___xyz_finder.py"], []), + (["bar/__init__.py", "__editable___xyz_finder.py"], ["bar"]), ], ) def test_iter_rewritable_modules(self, names, expected) -> None: From ff2b7e38ecfbc3f78f825ef0afa0a0c531836f5b Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 26 Aug 2022 09:37:41 -0300 Subject: [PATCH 4/4] Add CHANGELOG entry --- changelog/10230.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/10230.bugfix.rst diff --git a/changelog/10230.bugfix.rst b/changelog/10230.bugfix.rst new file mode 100644 index 00000000000..6ca2b00bf89 --- /dev/null +++ b/changelog/10230.bugfix.rst @@ -0,0 +1 @@ +Ignore ``.py`` files created by ``pyproject.toml``-based editable builds introduced in `pip 21.3 `__.