Port to Python 3.
[catacomb-python] / t / t-bytes.py
index 36a3f9f..27b7e49 100644 (file)
@@ -47,10 +47,16 @@ class TestByteString (U.TestCase):
 
     x = C.ByteString(T.bin("once upon a time there was a string"))
 
-    ## Check that simple indexing works.
-    me.assertEqual(type(x[3]), C.ByteString)
-    me.assertEqual(x[3], 'e')
-    me.assertEqual(x[-5], 't')
+    ## Check that simple indexing works.  Alas the behaviour differs between
+    ## Python major versions.
+    if T.PY3:
+      me.assertEqual(type(x[3]), int)
+      me.assertEqual(x[3], 101)
+      me.assertEqual(x[-5], 116)
+    else:
+      me.assertEqual(type(x[3]), C.ByteString)
+      me.assertEqual(x[3], 'e')
+      me.assertEqual(x[-5], 't')
 
     ## Check out-of-range detection.
     x[34]; me.assertRaises(IndexError, lambda: x[35])