[pypy-commit] pypy cpyext-unhashable: add passing tests
mattip
pypy.commits at gmail.com
Mon May 22 11:35:13 EDT 2017
Author: Matti Picus <matti.picus at gmail.com>
Branch: cpyext-unhashable
Changeset: r91371:21ce0ac7d0de
Date: 2017-05-22 18:34 +0300
http://bitbucket.org/pypy/pypy/changeset/21ce0ac7d0de/
Log: add passing tests
diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -143,6 +143,13 @@
assert fuu2(u"abc").baz().escape()
raises(TypeError, module.fooType.object_member.__get__, 1)
+ def test_hash_subtype(self):
+ module = self.import_module(name='foo')
+ newobj = module.UnicodeSubtype(u"xyz")
+ assert hash(newobj) == hash(u"xyz")
+ assert hash(module.UnicodeSubtype(u"")) in [0, -2]
+
+
def test_multiple_inheritance1(self):
module = self.import_module(name='foo')
obj = module.UnicodeSubtype(u'xyz')
diff --git a/pypy/objspace/std/test/test_bytesobject.py b/pypy/objspace/std/test/test_bytesobject.py
--- a/pypy/objspace/std/test/test_bytesobject.py
+++ b/pypy/objspace/std/test/test_bytesobject.py
@@ -741,7 +741,6 @@
def test_hash(self):
# check that we have the same hash as CPython for at least 31 bits
# (but don't go checking CPython's special case -1)
- # disabled: assert hash('') == 0 --- different special case
assert hash('hello') & 0x7fffffff == 0x347697fd
assert hash('hello world!') & 0x7fffffff == 0x2f0bb411
assert hash('') in [0, -2]
diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -1012,3 +1012,7 @@
raises(TypeError, "unicode('', encoding=None)")
raises(TypeError, 'u"".encode("utf-8", None)')
+ def test_hash(self):
+ assert hash(u'hello') & 0x7fffffff == 0x347697fd
+ assert hash(u'hello world!') & 0x7fffffff == 0x2f0bb411
+ assert hash(u'') in [0, -2]
More information about the pypy-commit
mailing list