Browse Source

[1512] test different name hash values for a known pair.

added comments about the underlying assumption and what we should do
if that isn't held.
JINMEI Tatuya 13 years ago
parent
commit
e2706e3bf5
1 changed files with 13 additions and 2 deletions
  1. 13 2
      src/lib/dns/python/tests/name_python_test.py

+ 13 - 2
src/lib/dns/python/tests/name_python_test.py

@@ -223,8 +223,19 @@ class NameTest(unittest.TestCase):
         self.assertEqual(hash(Name('example.com')), hash(Name('example.com')))
         # Hash is case insensitive.
         self.assertEqual(hash(Name('example.com')), hash(Name('EXAMPLE.COM')))
-        # We cannot reliably test the case for different hash values, but
-        # we can at least confirm inequality is case insensitive.
+
+        # These pairs happen to be known to have different hashes.
+        # It may be naive to assume the hash value is always the same (we use
+        # an external library and it depends on its internal details).  If
+        # it turns out that this assumption isn't always held, we should
+        # disable this test.
+        self.assertNotEqual(hash(Name('example.com')),
+                            hash(Name('example.org')))
+
+        # Check insensitiveness for the case of inequality.
+        # Based on the assumption above, this 'if' should be true and
+        # we'll always test the case inside it.  We'll still keep the if in
+        # case we end up disabling the above test.
         if hash(Name('example.com')) != hash(Name('example.org')):
             self.assertNotEqual(hash(Name('example.com')),
                                 hash(Name('EXAMPLE.ORG')))