[Jython-checkins] jython: Improve coverage of map types available from Java in test_dict_jy.
jeff.allen
jython-checkins at python.org
Thu Mar 28 04:57:03 EDT 2019
https://hg.python.org/jython/rev/cb8787723e59
changeset: 8230:cb8787723e59
user: Jeff Allen <ja.py at farowl.co.uk>
date: Mon Mar 25 06:06:52 2019 +0000
summary:
Improve coverage of map types available from Java in test_dict_jy.
Adds test of repr when dictionaries contain unicode keys or values (bjo #2649).
Extends all dictionary tests to 4 major Java containers, requiring some skips
for failing tests now lodged as bjo #2746.
files:
Lib/test/test_dict_jy.py | 67 ++++++++++++++++++++++++++-
1 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_dict_jy.py b/Lib/test/test_dict_jy.py
--- a/Lib/test/test_dict_jy.py
+++ b/Lib/test/test_dict_jy.py
@@ -245,12 +245,12 @@
type2test = Hashtable
class JavaConcurrentHashMapTest(JavaIntegrationTest):
- type2test = HashMap
+ type2test = ConcurrentHashMap
class JavaDictTest(test_dict.DictTest):
- _class = HashMap
+ _class = dict
def test_copy_java_hashtable(self):
x = Hashtable()
@@ -288,6 +288,27 @@
with self.assertRaises(AssertionError):
prop(self._make_dict(a), b)
+ # Some variants with unicode keys
+
+ @unittest.skip("FIXME: failing test for bjo #2649")
+ def test_repr_unicode(self):
+ d = self._make_dict({})
+ d[u'3\uc6d4'] = 2
+ self.assertEqual(repr(d), "{u'3\uc6d4': 2}")
+
+ d = self._make_dict({})
+ d[2] = u'\u039c\u03ac\u03c1\u03c4\u03b9\u03bf\u03c2'
+ self.assertEqual(repr(d), "{2: u'\u039c\u03ac\u03c1\u03c4\u03b9\u03bf\u03c2'}")
+
+ d = self._make_dict({})
+ d[u'\uc6d4'] = d
+ self.assertEqual(repr(d), "{u'\uc6d4': {...}}")
+
+ def test_fromkeys_unicode(self):
+ super(JavaDictTest, self).test_fromkeys()
+ self.assertEqual(self._class.fromkeys(u'\U00010840\U00010841\U00010842'),
+ {u'\U00010840':None, u'\U00010841':None, u'\U00010842':None})
+
# NOTE: when comparing dictionaries below exclusively in Java
# space, keys like 1 and 1L are different objects. Only when they
# are brought into Python space by Py.java2py, as is needed when
@@ -327,7 +348,7 @@
self.assertGreater({1L: 2L, 3L: 4L}, self._make_dict({1: 2}))
-class PyStringMapTest(test_dict.DictTest):
+class PyStringMapDictTest(test_dict.DictTest):
# __dict__ for objects uses PyStringMap for historical reasons, so
# we have to test separately
@@ -343,6 +364,38 @@
return newdict
+class JavaHashMapDictTest(JavaDictTest):
+ _class = HashMap
+
+class JavaLinkedHashMapDictTest(JavaDictTest):
+ _class = LinkedHashMap
+
+class JavaHashtableDictTest(JavaDictTest):
+ _class = Hashtable
+
+ @unittest.skip("FIXME: see bjo #2746")
+ def test_has_key(self): pass # defining here only so we can skip it
+
+ @unittest.skip("FIXME: see bjo #2746")
+ def test_keys(self): pass # defining here only so we can skip it
+
+ @unittest.skip("FIXME: see bjo #2746")
+ def test_repr_value_None(self): pass # defining here only so we can skip it
+
+
+class JavaConcurrentHashMapDictTest(JavaDictTest):
+ _class = ConcurrentHashMap
+
+ @unittest.skip("FIXME: see bjo #2746")
+ def test_has_key(self): pass # defining here only so we can skip it
+
+ @unittest.skip("FIXME: see bjo #2746")
+ def test_keys(self): pass # defining here only so we can skip it
+
+ @unittest.skip("FIXME: see bjo #2746")
+ def test_repr_value_None(self): pass # defining here only so we can skip it
+
+
def test_main():
test_support.run_unittest(
DictInitTest,
@@ -354,7 +407,13 @@
JavaConcurrentHashMapTest,
JavaHashtableTest,
JavaDictTest,
- PyStringMapTest)
+ PyStringMapDictTest,
+ JavaHashMapDictTest,
+ JavaLinkedHashMapDictTest,
+ JavaHashtableDictTest,
+ JavaConcurrentHashMapDictTest,
+ )
+
if __name__ == '__main__':
test_main()
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list