launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26312
[Merge] ~cjwatson/launchpad:py3-test-export-result-non-ascii into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-test-export-result-non-ascii into launchpad:master.
Commit message:
Fix ExportResult non-ASCII error test for Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398032
It's not clear that it's possible to trigger this failure mode in Python 3 at all, but it's awkward to conditionally skip just part of a doctest. For now, inject a mock exception to simulate the UnicodeDecodeError case.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-test-export-result-non-ascii into launchpad:master.
diff --git a/lib/lp/translations/doc/poexport-queue.txt b/lib/lp/translations/doc/poexport-queue.txt
index 2659006..7854639 100644
--- a/lib/lp/translations/doc/poexport-queue.txt
+++ b/lib/lp/translations/doc/poexport-queue.txt
@@ -134,7 +134,19 @@ Those are specially handled and reported.
... raise AssertionError(b"Really nasty \xc3 non-ASCII error!")
... except AssertionError:
... result.addFailure()
+
+It's not clear that it's possible to trigger this failure mode normally on
+Python 3 at all, because bytes will just be formatted as b'...'. For now,
+inject a mock exception in that case so that the test can pass.
+
+ >>> if six.PY3:
+ ... from lp.services.compat import mock
+ ... patcher = mock.patch.object(result, 'failure')
+ ... mock_failure = patcher.start()
+ ... mock_failure.__str__.side_effect = lambda: b'\xc3'.decode('UTF-8')
>>> result.notify()
+ >>> if six.PY3:
+ ... patcher.stop()
>>> test_emails = pop_notifications()
>>> len(test_emails)