diff options
author | Ezio Melotti <none@none> | 2011-04-26 05:12:51 +0300 |
---|---|---|
committer | Ezio Melotti <none@none> | 2011-04-26 05:12:51 +0300 |
commit | e3685f6b1b27bf089a40a12492f952dda5ff3ea2 (patch) | |
tree | c203d4df92443193797fd04fe93508711c280b92 /Lib/test/test_str.py | |
parent | a0895db2e1e94a7a2dfba4f75475975720aae224 (diff) | |
download | cpython-git-e3685f6b1b27bf089a40a12492f952dda5ff3ea2.tar.gz |
#6780: fix starts/endswith error message to mention that tuples are accepted too.
Diffstat (limited to 'Lib/test/test_str.py')
-rw-r--r-- | Lib/test/test_str.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py index 4f88b28848..2ecf3276b4 100644 --- a/Lib/test/test_str.py +++ b/Lib/test/test_str.py @@ -414,7 +414,18 @@ class StrTest( self.assertEqual('Andr\202 x'.decode('ascii', 'replace'), 'Andr\202 x'.decode(encoding='ascii', errors='replace')) - + def test_startswith_endswith_errors(self): + with self.assertRaises(UnicodeDecodeError): + '\xff'.startswith(u'x') + with self.assertRaises(UnicodeDecodeError): + '\xff'.endswith(u'x') + for meth in ('foo'.startswith, 'foo'.endswith): + with self.assertRaises(TypeError) as cm: + meth(['f']) + exc = str(cm.exception) + self.assertIn('unicode', exc) + self.assertIn('str', exc) + self.assertIn('tuple', exc) def test_main(): test_support.run_unittest(StrTest) |