launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29439
[Merge] ~cjwatson/launchpad:factory-proxy-previewdiff into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:factory-proxy-previewdiff into launchpad:master.
Commit message:
Return proxied object from makePreviewDiff
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/433675
`LaunchpadObjectFactory` issues `UnproxiedFactoryMethodWarning` when its methods return objects not wrapped in a security proxy, since that tends to result in tests that are less accurate simulations of production.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:factory-proxy-previewdiff into launchpad:master.
diff --git a/lib/lp/code/model/tests/test_branchmergeproposal.py b/lib/lp/code/model/tests/test_branchmergeproposal.py
index a404d5e..17d2f12 100644
--- a/lib/lp/code/model/tests/test_branchmergeproposal.py
+++ b/lib/lp/code/model/tests/test_branchmergeproposal.py
@@ -3131,7 +3131,7 @@ class TestWebservice(WebServiceTestCase):
def test_previewdiff_with_null_diffstat(self):
# A previewdiff with an empty diffstat doesn't crash when fetched.
previewdiff = self.factory.makePreviewDiff()
- previewdiff.diff.diffstat = None
+ removeSecurityProxy(previewdiff).diff.diffstat = None
user = previewdiff.branch_merge_proposal.target_branch.owner
ws_previewdiff = self.wsObject(previewdiff, user=user)
self.assertIsNone(ws_previewdiff.diffstat)
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 97151a1..b95c374 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -1888,7 +1888,7 @@ class LaunchpadObjectFactory(ObjectFactory):
preview_diff.target_revision_id = self.getUniqueUnicode()
if date_created:
preview_diff.date_created = date_created
- return preview_diff
+ return ProxyFactory(preview_diff)
def makeIncrementalDiff(
self, merge_proposal=None, old_revision=None, new_revision=None