[py-svn] r36131 - in py/dist/py/test: . testing

fijal at codespeak.net fijal at codespeak.net
Wed Jan 3 20:17:44 CET 2007


Author: fijal
Date: Wed Jan  3 20:17:40 2007
New Revision: 36131

Modified:
   py/dist/py/test/collect.py
   py/dist/py/test/testing/test_collect.py
Log:
Add __hash__ for items and test for it


Modified: py/dist/py/test/collect.py
==============================================================================
--- py/dist/py/test/collect.py	(original)
+++ py/dist/py/test/collect.py	Wed Jan  3 20:17:40 2007
@@ -102,6 +102,9 @@
         except AttributeError: 
             return False 
     
+    def __hash__(self):
+        return hash((self.name, self.parent))
+    
     def __ne__(self, other):
         return not self == other
 

Modified: py/dist/py/test/testing/test_collect.py
==============================================================================
--- py/dist/py/test/testing/test_collect.py	(original)
+++ py/dist/py/test/testing/test_collect.py	Wed Jan  3 20:17:40 2007
@@ -410,3 +410,30 @@
     l = list(col.tryiter(reporterror=errors.append))
     assert len(errors) == 0
 
+def test_check_collect_hashes():
+    tmp = py.test.ensuretemp("check_collect_hashes")
+    tmp.ensure("test_one.py").write(py.code.Source("""
+        def test_1():
+            pass
+        
+        def test_2():
+            pass
+    """))
+    tmp.ensure("test_two.py").write(py.code.Source("""
+        def test_1():
+            pass
+        
+        def test_2():
+            pass
+    """))
+    tmp.ensure("__init__.py")
+    col = py.test.collect.Directory(tmp)
+    errors = []
+    l = list(col.tryiter(reporterror=errors.append))
+    #assert len(errors) == 0
+    assert len(l) == 4
+    for numi, i in enumerate(l):
+        for numj, j in enumerate(l):
+            if numj != numi:
+                assert hash(i) != hash(j)
+                assert i != j



More information about the pytest-commit mailing list