Skip to content

Commit

Permalink
Merge pull request #725 from grouigrokon/fix-coverage-incompatibility
Browse files Browse the repository at this point in the history
Handle coverage module backward incompatibility
  • Loading branch information
grouigrokon authored May 29, 2024
2 parents e6ec589 + 4b2caa6 commit 542e641
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/e3/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,20 @@ def fix_coverage_paths(origin_dir: str, new_dir: str, cov_db: str) -> None:
old_coverage_data = CoverageData(old_cov_file.name)
old_coverage_data.read()
new_coverage_data = CoverageData(cov_db)
new_coverage_data.update(old_coverage_data, aliases=paths)

# Before 7.5.3, the map_path argument (of type Callable[[str], str])
# was named aliases (of type PathAliases). Try to handle the two
# possible APIs.
try:
# noinspection PyArgumentList
new_coverage_data.update(old_coverage_data, map_path=paths.map)
except TypeError as te:
if "got an unexpected keyword argument 'map_path'" in str(te):
# Try with the old API ...
# noinspection PyArgumentList
new_coverage_data.update(old_coverage_data, aliases=paths)
else:
raise te
new_coverage_data.write()
finally:
os.unlink(old_cov_file.name)
Expand Down

0 comments on commit 542e641

Please sign in to comment.