Skip to content

[7.1.x] Ignore editable installation modules #10249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/10230.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignore ``.py`` files created by ``pyproject.toml``-based editable builds introduced in `pip 21.3 <https://pip.pypa.io/en/stable/news/#v21-3>`__.
3 changes: 2 additions & 1 deletion src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,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:
Expand Down
6 changes: 3 additions & 3 deletions src/_pytest/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,15 @@ def _report_to_json(report: BaseReport) -> Dict[str, Any]:
def serialize_repr_entry(
entry: Union[ReprEntry, ReprEntryNative]
) -> Dict[str, Any]:
data = attr.asdict(entry)
data = attr.asdict(entry) # type:ignore[arg-type]
for key, value in data.items():
if hasattr(value, "__dict__"):
data[key] = attr.asdict(value)
entry_data = {"type": type(entry).__name__, "data": data}
return entry_data

def serialize_repr_traceback(reprtraceback: ReprTraceback) -> Dict[str, Any]:
result = attr.asdict(reprtraceback)
result = attr.asdict(reprtraceback) # type:ignore[arg-type]
result["reprentries"] = [
serialize_repr_entry(x) for x in reprtraceback.reprentries
]
Expand All @@ -473,7 +473,7 @@ def serialize_repr_crash(
reprcrash: Optional[ReprFileLocation],
) -> Optional[Dict[str, Any]]:
if reprcrash is not None:
return attr.asdict(reprcrash)
return attr.asdict(reprcrash) # type:ignore[arg-type]
else:
return None

Expand Down
3 changes: 3 additions & 0 deletions testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,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:
Expand Down