Skip to content

Commit 8f5088f

Browse files
authored
Merge pull request #10249 from pytest-dev/backport-10231-to-7.1.x
2 parents 89f7518 + aae93d6 commit 8f5088f

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

changelog/10230.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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>`__.

src/_pytest/config/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,8 @@ def _iter_rewritable_modules(package_files: Iterable[str]) -> Iterator[str]:
833833
if is_simple_module:
834834
module_name, _ = os.path.splitext(fn)
835835
# we ignore "setup.py" at the root of the distribution
836-
if module_name != "setup":
836+
# as well as editable installation finder modules made by setuptools
837+
if module_name != "setup" and not module_name.startswith("__editable__"):
837838
seen_some = True
838839
yield module_name
839840
elif is_package:

src/_pytest/reports.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,15 @@ def _report_to_json(report: BaseReport) -> Dict[str, Any]:
455455
def serialize_repr_entry(
456456
entry: Union[ReprEntry, ReprEntryNative]
457457
) -> Dict[str, Any]:
458-
data = attr.asdict(entry)
458+
data = attr.asdict(entry) # type:ignore[arg-type]
459459
for key, value in data.items():
460460
if hasattr(value, "__dict__"):
461461
data[key] = attr.asdict(value)
462462
entry_data = {"type": type(entry).__name__, "data": data}
463463
return entry_data
464464

465465
def serialize_repr_traceback(reprtraceback: ReprTraceback) -> Dict[str, Any]:
466-
result = attr.asdict(reprtraceback)
466+
result = attr.asdict(reprtraceback) # type:ignore[arg-type]
467467
result["reprentries"] = [
468468
serialize_repr_entry(x) for x in reprtraceback.reprentries
469469
]
@@ -473,7 +473,7 @@ def serialize_repr_crash(
473473
reprcrash: Optional[ReprFileLocation],
474474
) -> Optional[Dict[str, Any]]:
475475
if reprcrash is not None:
476-
return attr.asdict(reprcrash)
476+
return attr.asdict(reprcrash) # type:ignore[arg-type]
477477
else:
478478
return None
479479

testing/test_config.py

+3
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,9 @@ def test_confcutdir_check_isdir(self, pytester: Pytester) -> None:
837837
(["src/bar/__init__.py"], ["bar"]),
838838
(["src/bar/__init__.py", "setup.py"], ["bar"]),
839839
(["source/python/bar/__init__.py", "setup.py"], ["bar"]),
840+
# editable installation finder modules
841+
(["__editable___xyz_finder.py"], []),
842+
(["bar/__init__.py", "__editable___xyz_finder.py"], ["bar"]),
840843
],
841844
)
842845
def test_iter_rewritable_modules(self, names, expected) -> None:

0 commit comments

Comments
 (0)