diff options
author | Hynek Schlawack <hs@ox.cx> | 2012-07-17 08:50:30 (GMT) |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2012-07-17 08:50:30 (GMT) |
commit | 1c4eb2c09a69da989c2b0343e10e8c77f816771c (patch) | |
tree | 9bacecdb908fefae80b1aa2fb46f92997df7d93c /Lib/test/test_posixpath.py | |
parent | 426e248febc4b86ea4512baaaa81966ab54c83da (diff) | |
parent | 7cdc2bdd0d13982256fb28f49696fa70baab7ed0 (diff) | |
download | cpython-1c4eb2c09a69da989c2b0343e10e8c77f816771c.zip cpython-1c4eb2c09a69da989c2b0343e10e8c77f816771c.tar.gz cpython-1c4eb2c09a69da989c2b0343e10e8c77f816771c.tar.bz2 |
Fix context manager use in posixpath.join() tests
The asserts were useless (and buggy).
Diffstat (limited to 'Lib/test/test_posixpath.py')
-rw-r--r-- | Lib/test/test_posixpath.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index 575e407..e89f22e 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -56,15 +56,18 @@ class PosixPathTest(unittest.TestCase): self.assertEqual(posixpath.join(b"/foo/", b"bar/", b"baz/"), b"/foo/bar/baz/") - 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]) + # Check for friendly str/bytes mixing message + for args in [[b'bytes', 'str'], + [bytearray(b'bytes'), 'str']]: + for _ in range(2): + with self.assertRaises(TypeError) as cm: + posixpath.join(*args) + self.assertEqual( + "Can't mix strings and bytes in path components.", + cm.exception.args[0] + ) + args.reverse() # check both orders + def test_split(self): self.assertEqual(posixpath.split("/foo/bar"), ("/foo", "bar")) |