mirror of
https://github.com/python/cpython.git
synced 2025-09-20 07:31:10 +00:00
Fix context manager use in posixpath.join() tests
The asserts were useless (and buggy).
This commit is contained in:
commit
1c4eb2c09a
1 changed files with 12 additions and 9 deletions
|
@ -56,15 +56,18 @@ class PosixPathTest(unittest.TestCase):
|
||||||
self.assertEqual(posixpath.join(b"/foo/", b"bar/", b"baz/"),
|
self.assertEqual(posixpath.join(b"/foo/", b"bar/", b"baz/"),
|
||||||
b"/foo/bar/baz/")
|
b"/foo/bar/baz/")
|
||||||
|
|
||||||
with self.assertRaises(TypeError) as e:
|
# Check for friendly str/bytes mixing message
|
||||||
posixpath.join(b'bytes', 'str')
|
for args in [[b'bytes', 'str'],
|
||||||
self.assertIn("Can't mix strings and bytes", e.args[0])
|
[bytearray(b'bytes'), 'str']]:
|
||||||
with self.assertRaises(TypeError) as e:
|
for _ in range(2):
|
||||||
posixpath.join('str', b'bytes')
|
with self.assertRaises(TypeError) as cm:
|
||||||
self.assertIn("Can't mix strings and bytes", e.args[0])
|
posixpath.join(*args)
|
||||||
with self.assertRaises(TypeError) as e:
|
self.assertEqual(
|
||||||
posixpath.join('str', bytearray(b'bytes'))
|
"Can't mix strings and bytes in path components.",
|
||||||
self.assertIn("Can't mix strings and bytes", e.args[0])
|
cm.exception.args[0]
|
||||||
|
)
|
||||||
|
args.reverse() # check both orders
|
||||||
|
|
||||||
|
|
||||||
def test_split(self):
|
def test_split(self):
|
||||||
self.assertEqual(posixpath.split("/foo/bar"), ("/foo", "bar"))
|
self.assertEqual(posixpath.split("/foo/bar"), ("/foo", "bar"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue