diff options
| author | Hynek Schlawack <hs@ox.cx> | 2012-07-15 14:46:23 (GMT) |
|---|---|---|
| committer | Hynek Schlawack <hs@ox.cx> | 2012-07-15 14:46:23 (GMT) |
| commit | 9ac4d8808f21869c558f2d9fd5e46cb083443ea8 (patch) | |
| tree | 92bb2521ffb02b6d46a3bfb8caaf34d7b134b756 /Lib/test/test_posixpath.py | |
| parent | b7a5894c64f4ac8353a90e518433cfe025b5b5bc (diff) | |
| parent | 4774946c3b7564b4a1c93da4ba4dba443a36a708 (diff) | |
| download | cpython-9ac4d8808f21869c558f2d9fd5e46cb083443ea8.zip cpython-9ac4d8808f21869c558f2d9fd5e46cb083443ea8.tar.gz cpython-9ac4d8808f21869c558f2d9fd5e46cb083443ea8.tar.bz2 | |
#15180: Clarify posixpath.join() error message when mixing str & bytes
Diffstat (limited to 'Lib/test/test_posixpath.py')
| -rw-r--r-- | Lib/test/test_posixpath.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index daebeaa..575e407 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -56,8 +56,15 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(posixpath.join(b"/foo/", b"bar/", b"baz/"), b"/foo/bar/baz/") - self.assertRaises(TypeError, posixpath.join, b"bytes", "str") - self.assertRaises(TypeError, posixpath.join, "str", b"bytes") + with self.assertRaises(TypeError) as e: + posixpath.join(b'bytes', 'str') + self.assertIn("Can't mix strings and bytes", e.args[0]) + with self.assertRaises(TypeError) as e: + posixpath.join('str', b'bytes') + self.assertIn("Can't mix strings and bytes", e.args[0]) + with self.assertRaises(TypeError) as e: + posixpath.join('str', bytearray(b'bytes')) + self.assertIn("Can't mix strings and bytes", e.args[0]) def test_split(self): self.assertEqual(posixpath.split("/foo/bar"), ("/foo", "bar")) |
