Rev 4771: Add some tests that we *can* compare to strings, even if we don't care in http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple-no-use

John Arbash Meinel john at arbash-meinel.com
Mon Oct 12 19:10:27 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple-no-use

------------------------------------------------------------
revno: 4771
revision-id: john at arbash-meinel.com-20091012181024-q21zm9xpyf62ld7t
parent: john at arbash-meinel.com-20091012180602-1zgs701z6oj3knb3
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-static-tuple-no-use
timestamp: Mon 2009-10-12 13:10:24 -0500
message:
  Add some tests that we *can* compare to strings, even if we don't care
  what the result actually is.
-------------- next part --------------
=== modified file 'bzrlib/tests/test__static_tuple.py'
--- a/bzrlib/tests/test__static_tuple.py	2009-10-12 17:50:58 +0000
+++ b/bzrlib/tests/test__static_tuple.py	2009-10-12 18:10:24 +0000
@@ -208,13 +208,29 @@
         self.assertTrue(k_small <= k_big)
         self.assertTrue(k_small < k_big)
 
+    def assertCompareNoRelation(self, k1, k2):
+        """Run the comparison operators, make sure they do something.
+
+        However, we don't actually care what comes first or second. This is
+        stuff like cross-class comparisons. We don't want to segfault/raise an
+        exception, but we don't care about the sort order.
+        """
+        self.assertFalse(k1 == k2)
+        self.assertTrue(k1 != k2)
+        # Do the comparison, but we don't care about the result
+        k1 >= k2
+        k1 > k2
+        k1 <= k2
+        k1 < k2
+
     def test_compare_vs_none(self):
         k1 = self.module.StaticTuple('baz', 'bing')
         self.assertCompareDifferent(None, k1)
-        self.assertCompareDifferent(10, k1)
-        # Comparison with a string is poorly-defined, I seem to get failures
-        # regardless of which one comes first...
-        # self.assertCompareDifferent('baz', k1)
+    
+    def test_compare_cross_class(self):
+        k1 = self.module.StaticTuple('baz', 'bing')
+        self.assertCompareNoRelation(10, k1)
+        self.assertCompareNoRelation('baz', k1)
 
     def test_compare_all_different_same_width(self):
         k1 = self.module.StaticTuple('baz', 'bing')



More information about the bazaar-commits mailing list