10000 Add tests for comparing (unicode) strings to incompatible types · thecodingchicken/python-future@f4aff0b · GitHub
[go: up one dir, main page]

Skip to content

Commit f4aff0b

Browse files
committed
Add tests for comparing (unicode) strings to incompatible types
- Py3 is stricter about this than Py2.
1 parent f9e2f3b commit f4aff0b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

future/tests/test_str.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,21 @@ def test_ne(self):
256256
self.assertTrue(b'ABCD' != s)
257257
self.assertTrue(bytes(b'ABCD') != s)
258258

259+
def test_cmp(self):
260+
s = str(u'ABC')
261+
with self.assertRaises(TypeError):
262+
s > 3
263+
with self.assertRaises(TypeError):
264+
s < 1000
265+
with self.assertRaises(TypeError):
266+
s > b'XYZ'
267+
with self.assertRaises(TypeError):
268+
s < b'XYZ'
269+
with self.assertRaises(TypeError):
270+
s <= 3
271+
with self.assertRaises(TypeError):
272+
s >= int(3)
273+
259274

260275
if __name__ == '__main__':
261276
unittest.main()

0 commit comments

Comments
 (0)
0