[Jython-checkins] jython: Add test on subclassing bytearray, then using __len__

jim.baker jython-checkins at python.org
Fri May 23 20:53:22 CEST 2014


http://hg.python.org/jython/rev/2f8b6070b213
changeset:   7274:2f8b6070b213
user:        Jim Baker <jim.baker at rackspace.com>
date:        Fri May 23 12:32:44 2014 -0600
summary:
  Add test on subclassing bytearray, then using __len__

files:
  Lib/test/test_bytes_jy.py |  23 +++++++++++++++++++++++
  1 files changed, 23 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_bytes_jy.py b/Lib/test/test_bytes_jy.py
new file mode 100644
--- /dev/null
+++ b/Lib/test/test_bytes_jy.py
@@ -0,0 +1,23 @@
+# Tests against problems we have seen in Jython's implementation of
+# buffer, bytes, bytearray, and memoryview to prevent possible
+# regression as well as integration with Java.
+
+import unittest
+import test.test_support
+
+
+class ByteArraySubclassTest(unittest.TestCase):
+
+    def test_len(self):
+        class Sub(bytearray): pass
+        s = Sub("abc123")
+        self.assertEqual(len(s), 6)
+ 
+
+def test_main():
+    test.test_support.run_unittest(
+        ByteArraySubclassTest)
+
+
+if __name__ == "__main__":
+    test_main()

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list