[Python-checkins] cpython (merge 3.2 -> default): Fix context manager use in posixpath.join() tests
hynek.schlawack
python-checkins at python.org
Tue Jul 17 10:51:36 CEST 2012
http://hg.python.org/cpython/rev/59b4e979ad37
changeset: 78147:59b4e979ad37
parent: 78145:64ff90e07d71
parent: 78146:eddafae5e575
user: Hynek Schlawack <hs at ox.cx>
date: Tue Jul 17 10:50:30 2012 +0200
summary:
Fix context manager use in posixpath.join() tests
The asserts were useless (and buggy).
files:
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
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -56,15 +56,18 @@
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"))
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list