diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-05-03 21:05:51 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-05-03 21:05:51 (GMT) |
commit | aa97f0496412ed834aada921e29588ed16d68e40 (patch) | |
tree | cfe74cb3cd3ed5a27cbcfa404ea9fc8c73fd63f1 /Lib/test/test_unicode.py | |
parent | 5d7a7001d9df605606b249b3e11707d6d1ad2e3d (diff) | |
download | cpython-aa97f0496412ed834aada921e29588ed16d68e40.zip cpython-aa97f0496412ed834aada921e29588ed16d68e40.tar.gz cpython-aa97f0496412ed834aada921e29588ed16d68e40.tar.bz2 |
Fix various spots where int/long and str/unicode unification
lead to type checks like isinstance(foo, (str, str)) or
isinstance(foo, (int, int)).
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r-- | Lib/test/test_unicode.py | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 3dd92ae..ccfa922 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -134,31 +134,27 @@ class UnicodeTest( def test_index(self): string_tests.CommonTest.test_index(self) - # check mixed argument types - for (t1, t2) in ((str, str), (str, str)): - self.checkequalnofix(0, t1('abcdefghiabc'), 'index', t2('')) - self.checkequalnofix(3, t1('abcdefghiabc'), 'index', t2('def')) - self.checkequalnofix(0, t1('abcdefghiabc'), 'index', t2('abc')) - self.checkequalnofix(9, t1('abcdefghiabc'), 'index', t2('abc'), 1) - self.assertRaises(ValueError, t1('abcdefghiabc').index, t2('hib')) - self.assertRaises(ValueError, t1('abcdefghiab').index, t2('abc'), 1) - self.assertRaises(ValueError, t1('abcdefghi').index, t2('ghi'), 8) - self.assertRaises(ValueError, t1('abcdefghi').index, t2('ghi'), -1) + self.checkequalnofix(0, 'abcdefghiabc', 'index', '') + self.checkequalnofix(3, 'abcdefghiabc', 'index', 'def') + self.checkequalnofix(0, 'abcdefghiabc', 'index', 'abc') + self.checkequalnofix(9, 'abcdefghiabc', 'index', 'abc', 1) + self.assertRaises(ValueError, 'abcdefghiabc'.index, 'hib') + self.assertRaises(ValueError, 'abcdefghiab'.index, 'abc', 1) + self.assertRaises(ValueError, 'abcdefghi'.index, 'ghi', 8) + self.assertRaises(ValueError, 'abcdefghi'.index, 'ghi', -1) def test_rindex(self): string_tests.CommonTest.test_rindex(self) - # check mixed argument types - for (t1, t2) in ((str, str), (str, str)): - self.checkequalnofix(12, t1('abcdefghiabc'), 'rindex', t2('')) - self.checkequalnofix(3, t1('abcdefghiabc'), 'rindex', t2('def')) - self.checkequalnofix(9, t1('abcdefghiabc'), 'rindex', t2('abc')) - self.checkequalnofix(0, t1('abcdefghiabc'), 'rindex', t2('abc'), 0, -1) - - self.assertRaises(ValueError, t1('abcdefghiabc').rindex, t2('hib')) - self.assertRaises(ValueError, t1('defghiabc').rindex, t2('def'), 1) - self.assertRaises(ValueError, t1('defghiabc').rindex, t2('abc'), 0, -1) - self.assertRaises(ValueError, t1('abcdefghi').rindex, t2('ghi'), 0, 8) - self.assertRaises(ValueError, t1('abcdefghi').rindex, t2('ghi'), 0, -1) + self.checkequalnofix(12, 'abcdefghiabc', 'rindex', '') + self.checkequalnofix(3, 'abcdefghiabc', 'rindex', 'def') + self.checkequalnofix(9, 'abcdefghiabc', 'rindex', 'abc') + self.checkequalnofix(0, 'abcdefghiabc', 'rindex', 'abc', 0, -1) + + self.assertRaises(ValueError, 'abcdefghiabc'.rindex, 'hib') + self.assertRaises(ValueError, 'defghiabc'.rindex, 'def', 1) + self.assertRaises(ValueError, 'defghiabc'.rindex, 'abc', 0, -1) + self.assertRaises(ValueError, 'abcdefghi'.rindex, 'ghi', 0, 8) + self.assertRaises(ValueError, 'abcdefghi'.rindex, 'ghi', 0, -1) def test_translate(self): self.checkequalnofix('bbbc', 'abababc', 'translate', {ord('a'):None}) |