[pypy-commit] pypy py3k: 2to3fy new hash test

rlamy pypy.commits at gmail.com
Thu Jul 28 15:03:08 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k
Changeset: r85898:345873925b96
Date: 2016-07-28 19:40 +0100
http://bitbucket.org/pypy/pypy/changeset/345873925b96/

Log:	2to3fy new hash test

diff --git a/pypy/objspace/test/test_descriptor.py b/pypy/objspace/test/test_descriptor.py
--- a/pypy/objspace/test/test_descriptor.py
+++ b/pypy/objspace/test/test_descriptor.py
@@ -81,29 +81,29 @@
         raises(AttributeError, delattr, x, '\ud800')
         raises(AttributeError, getattr, x, '\uDAD1\uD51E')
 
-    def test_special_methods_returning_strings(self): 
-        class A(object): 
+    def test_special_methods_returning_strings(self):
+        class A(object):
             seen = []
-            def __str__(self): 
-                self.seen.append(1) 
-            def __repr__(self): 
-                self.seen.append(2) 
-            def __oct__(self): 
-                self.seen.append(3) 
-            def __hex__(self): 
-                self.seen.append(4) 
+            def __str__(self):
+                self.seen.append(1)
+            def __repr__(self):
+                self.seen.append(2)
+            def __oct__(self):
+                self.seen.append(3)
+            def __hex__(self):
+                self.seen.append(4)
 
         inst = A()
-        raises(TypeError, str, inst) 
-        raises(TypeError, repr, inst) 
-        raises(TypeError, oct, inst) 
-        raises(TypeError, hex, inst) 
+        raises(TypeError, str, inst)
+        raises(TypeError, repr, inst)
+        raises(TypeError, oct, inst)
+        raises(TypeError, hex, inst)
         assert A.seen == [1,2] # __oct__ and __hex__ are no longer called
 
-    def test_hash(self): 
+    def test_hash(self):
         class A(object):
             pass
-        hash(A()) 
+        hash(A())
 
         class B(object):
             def __eq__(self, other): pass
@@ -111,7 +111,7 @@
         raises(TypeError, "hash(B())") # because we define __eq__ but not __hash__
 
         class E(object):
-            def __hash__(self): 
+            def __hash__(self):
                 return "something"
         raises(TypeError, hash, E())
 
@@ -128,31 +128,23 @@
                 return myint(15)
         assert hash(I()) == 15
         assert type(hash(I())) is int
-        
+
         # check hashing of -1 to -2
         class myint(int):
             pass
-        class mylong(long):
-            pass
         class myfloat(float):
             pass
         class myHashClass(object):
             def __hash__(self):
                 return -1
-        class myHashClass2(object):
-            def __hash__(self):
-                return -1L
         class myHashClass3(object):
             def __hash__(self):
                 return -10**100
 
         assert hash(-1) == -2
-        assert hash(-1L) == -2
         assert hash(-1.0) == -2
         assert hash(-1 + 0j) == -2
         assert hash(myint(-1)) == -2
-        assert hash(mylong(-1)) == -2
         assert hash(myfloat(-1.0)) == -2
         assert hash(myHashClass()) == -2
-        assert hash(myHashClass2()) == -2
         assert hash(myHashClass3()) == hash(-10**100)


More information about the pypy-commit mailing list