Skip to content

Commit

Permalink
tests: contextlib.suppress does not return anything (#9444)
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed May 27, 2024
1 parent 25b145a commit b32a260
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,13 @@ def switch_working_directory(path: Path, remove: bool = False) -> Iterator[Path]
original_cwd = Path.cwd()
os.chdir(path)

with contextlib.suppress(Exception) as exception:
try:
yield path
finally:
os.chdir(original_cwd)

os.chdir(original_cwd)

if remove:
shutil.rmtree(path, ignore_errors=True)

if exception is not None:
raise exception
if remove:
shutil.rmtree(path, ignore_errors=True)


@contextlib.contextmanager
Expand Down

0 comments on commit b32a260

Please sign in to comment.