diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2021-10-20 20:55:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-20 20:55:46 -0700 |
commit | c52338fc42353e8d0c6214e4c22427807439dfd5 (patch) | |
tree | 6da4bf5da5eb739aa48eab1850218d5726c45b10 /Lib/test/test_tempfile.py | |
parent | 8f05ffb0534c2343fc45ad0e1d91ae1dc2d92b64 (diff) | |
parent | 2a9ab75af32b1ee9f210ae2a0718990687d0f79d (diff) | |
download | cpython-git-enum-private-310.tar.gz |
Merge branch '3.10' into enum-private-310enum-private-310
Diffstat (limited to 'Lib/test/test_tempfile.py')
-rw-r--r-- | Lib/test/test_tempfile.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index 96946a281a..2b0ec46a10 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -62,6 +62,25 @@ class TestLowLevelInternals(unittest.TestCase): def test_infer_return_type_pathlib(self): self.assertIs(str, tempfile._infer_return_type(pathlib.Path('/'))) + def test_infer_return_type_pathlike(self): + class Path: + def __init__(self, path): + self.path = path + + def __fspath__(self): + return self.path + + self.assertIs(str, tempfile._infer_return_type(Path('/'))) + self.assertIs(bytes, tempfile._infer_return_type(Path(b'/'))) + self.assertIs(str, tempfile._infer_return_type('', Path(''))) + self.assertIs(bytes, tempfile._infer_return_type(b'', Path(b''))) + self.assertIs(bytes, tempfile._infer_return_type(None, Path(b''))) + self.assertIs(str, tempfile._infer_return_type(None, Path(''))) + + with self.assertRaises(TypeError): + tempfile._infer_return_type('', Path(b'')) + with self.assertRaises(TypeError): + tempfile._infer_return_type(b'', Path('')) # Common functionality. |