Merge lp:~gz/testtools/fix_json_py3k_tests into lp:~testtools-committers/testtools/trunk
Status: | Merged |
---|---|
Approved by: | Jonathan Lange |
Approved revision: | 269 |
Merged at revision: | 278 |
Proposed branch: | lp:~gz/testtools/fix_json_py3k_tests |
Merge into: | lp:~testtools-committers/testtools/trunk |
Diff against target: |
87 lines (+15/-8) 5 files modified
testtools/content.py (+6/-2) testtools/tests/test_content.py (+1/-1) testtools/tests/test_content_type.py (+2/-2) testtools/tests/test_testcase.py (+3/-2) testtools/tests/test_testresult.py (+3/-1) |
To merge this branch: | bzr merge lp:~gz/testtools/fix_json_py3k_tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Lange | Approve | ||
Review via email: mp+117117@code.launchpad.net |
Commit message
Testing. Please ignore.
Description of the change
Makes the current status of testtools a little greener.
There was a small amount of fallout from the json content type branch, most notably the helper does the wrong thing on Python 3 as json.dumps returns str, not bytes.
Also some other trivial fixes for tests on Python 3, but there's one failure I've not resolved:
=======
ERROR: testtools.
-------
Traceback (most recent call last):
File "testtools\
self.
File "testtools\
expected = sorted(
TypeError: unorderable types: dict() < int()
The SameMembers implementation just doesn't make sense given that Python 3 refuses to assign order to unrelated types.
Something dumb like this makes the tests pass, but only because they're not very comprehensive:
=== modified file 'testtools/
--- testtools/
+++ testtools/
@@ -1291,9 +1294,13 @@
def __str__(self):
return '%s(%r)' % (self._
+ @staticmethod
+ def _by_type_
+ return type(obj).__name__, obj
+
def match(self, observed):
- expected = sorted(
- observed = sorted(observed)
+ expected = sorted(
+ observed = sorted(observed, key=self.
if expected == observed:
return
return _BinaryMismatch
That falls down if, for instance, you're expecting [1] and [1.0] to compare equal. Either there's a better way, or this matcher is just a bad idea.
LGTM. I'll file a bug for SameMembers and hopefully fix. Thanks!