← Back to team overview

testtools-dev team mailing list archive

[Merge] lp:~jml/testtools/unbreak-tests into lp:testtools

 

Jonathan Lange has proposed merging lp:~jml/testtools/unbreak-tests into lp:testtools.

Requested reviews:
  testtools committers (testtools-committers)

For more details, see:
https://code.launchpad.net/~jml/testtools/unbreak-tests/+merge/119130


-- 
https://code.launchpad.net/~jml/testtools/unbreak-tests/+merge/119130
Your team testtools developers is subscribed to branch lp:testtools.
=== modified file 'testtools/content.py'
--- testtools/content.py	2012-07-13 16:21:45 +0000
+++ testtools/content.py	2012-08-10 13:44:21 +0000
@@ -192,7 +192,7 @@
 
 def json_content(data):
     """Create a JSON `Content` object from JSON-encodeable data."""
-    return Content(JSON, lambda: [json.dumps(data)])
+    return Content(JSON, lambda: [json.dumps(data).encode('utf8')])
 
 
 def text_content(text):

=== modified file 'testtools/matchers.py'
--- testtools/matchers.py	2012-08-10 13:10:30 +0000
+++ testtools/matchers.py	2012-08-10 13:44:21 +0000
@@ -1369,11 +1369,15 @@
         return '%s(%r)' % (self.__class__.__name__, self.expected)
 
     def match(self, observed):
-        expected = sorted(self.expected)
-        observed = sorted(observed)
-        if expected == observed:
+        observed_only = [o for o in observed if o not in list(self.expected)]
+        expected_only = [o for o in self.expected if o not in list(observed)]
+        if expected_only == observed_only == []:
             return
-        return _BinaryMismatch(expected, "elements differ", observed)
+        return _BinaryMismatch(
+            self.expected, 'elements differ', observed)
+        return Mismatch(
+            "Missing: %s\nExtra: %s" % (
+                _format(expected_only), _format(observed_only)))
 
 
 class HasPermissions(Matcher):

=== modified file 'testtools/tests/test_content.py'
--- testtools/tests/test_content.py	2012-07-13 16:21:45 +0000
+++ testtools/tests/test_content.py	2012-08-10 13:44:21 +0000
@@ -154,8 +154,8 @@
         self.assertEqual(expected, text_content(data))
 
     def test_json_content(self):
-        data = {'foo': 'bar'}
-        expected = Content(JSON, lambda: [json.dumps(data)])
+        data = {_u('foo'): _u('bar')}
+        expected = Content(JSON, lambda: [json.dumps(data).encode('utf8')])
         self.assertEqual(expected, json_content(data))
 
 

=== modified file 'testtools/tests/test_matchers.py'
--- testtools/tests/test_matchers.py	2012-08-10 13:10:30 +0000
+++ testtools/tests/test_matchers.py	2012-08-10 13:44:21 +0000
@@ -1139,8 +1139,8 @@
 
     describe_examples = [
         (("elements differ:\n"
-          "reference = ['apple', 'banana', 'canteloupe', 'lemon', 'orange', 'watermelon']\n"
-          "actual    = ['apple', 'banana', 'canteloupe', 'lemon', 'orange', 'sparrow']\n"),
+          "reference = ['apple', 'orange', 'canteloupe', 'watermelon', 'lemon', 'banana']\n"
+          "actual    = ['orange', 'apple', 'banana', 'sparrow', 'lemon', 'canteloupe']\n"),
          ['orange', 'apple', 'banana', 'sparrow', 'lemon', 'canteloupe',],
          SameMembers(
              ['apple', 'orange', 'canteloupe', 'watermelon',


Follow ups