Skip to content

Commit

Permalink
remove pathlib.Path use as a contextmanager
Browse files Browse the repository at this point in the history
Path as a contextmanager is deprecated from 3.11 onwards, and was a
no-op since Python 3.9. Also this functionality was never documented.

See [cpython/Lib/pathlib.py#L810-L816][1], python/cpython#83863 and, python/cpython#90714.

[1]: https://github.com/python/cpython/blob/120b4ab2b68aebf96ce0de243eab89a25fc2d282/Lib/pathlib.py#L810-L816
  • Loading branch information
skshetry authored and pixelb committed Oct 17, 2022
1 parent 9ce6720 commit 5300a86
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def test_number_of_imports(tmpdir: Path) -> None:
x.__name__ for x in Plugins.instance().discover(Plugin)
]

with Path(os.environ["TMP_FILE"]) as f:
txt = str(f.read_text())
assert txt.split("\n").count("imported") == 1
f = Path(os.environ["TMP_FILE"])
txt = str(f.read_text())
assert txt.split("\n").count("imported") == 1


def test_skipped_imports(tmpdir: Path) -> None:
Expand Down

0 comments on commit 5300a86

Please sign in to comment.