Merge pull request #10249 from pytest-dev/backport-10231-to-7.1.x

This commit is contained in:
Bruno Oliveira 2022-08-26 11:13:25 -03:00 committed by GitHub
commit 8f5088f412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View File

@ -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>`__.

View File

@ -833,7 +833,8 @@ def _iter_rewritable_modules(package_files: Iterable[str]) -> Iterator[str]:
if is_simple_module: if is_simple_module:
module_name, _ = os.path.splitext(fn) module_name, _ = os.path.splitext(fn)
# we ignore "setup.py" at the root of the distribution # 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 seen_some = True
yield module_name yield module_name
elif is_package: elif is_package:

View File

@ -455,7 +455,7 @@ def _report_to_json(report: BaseReport) -> Dict[str, Any]:
def serialize_repr_entry( def serialize_repr_entry(
entry: Union[ReprEntry, ReprEntryNative] entry: Union[ReprEntry, ReprEntryNative]
) -> Dict[str, Any]: ) -> Dict[str, Any]:
data = attr.asdict(entry) data = attr.asdict(entry) # type:ignore[arg-type]
for key, value in data.items(): for key, value in data.items():
if hasattr(value, "__dict__"): if hasattr(value, "__dict__"):
data[key] = attr.asdict(value) data[key] = attr.asdict(value)
@ -463,7 +463,7 @@ def _report_to_json(report: BaseReport) -> Dict[str, Any]:
return entry_data return entry_data
def serialize_repr_traceback(reprtraceback: ReprTraceback) -> Dict[str, Any]: def serialize_repr_traceback(reprtraceback: ReprTraceback) -> Dict[str, Any]:
result = attr.asdict(reprtraceback) result = attr.asdict(reprtraceback) # type:ignore[arg-type]
result["reprentries"] = [ result["reprentries"] = [
serialize_repr_entry(x) for x in reprtraceback.reprentries serialize_repr_entry(x) for x in reprtraceback.reprentries
] ]
@ -473,7 +473,7 @@ def _report_to_json(report: BaseReport) -> Dict[str, Any]:
reprcrash: Optional[ReprFileLocation], reprcrash: Optional[ReprFileLocation],
) -> Optional[Dict[str, Any]]: ) -> Optional[Dict[str, Any]]:
if reprcrash is not None: if reprcrash is not None:
return attr.asdict(reprcrash) return attr.asdict(reprcrash) # type:ignore[arg-type]
else: else:
return None return None

View File

@ -837,6 +837,9 @@ class TestConfigAPI:
(["src/bar/__init__.py"], ["bar"]), (["src/bar/__init__.py"], ["bar"]),
(["src/bar/__init__.py", "setup.py"], ["bar"]), (["src/bar/__init__.py", "setup.py"], ["bar"]),
(["source/python/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: def test_iter_rewritable_modules(self, names, expected) -> None: