← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:factory-proxy-branchrevision into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:factory-proxy-branchrevision into launchpad:master.

Commit message:
Return proxied objects from makeBranchRevision

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/434695

`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.

This required tightening up one test.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:factory-proxy-branchrevision into launchpad:master.
diff --git a/lib/lp/code/model/tests/test_diff.py b/lib/lp/code/model/tests/test_diff.py
index 833e04e..afb7d90 100644
--- a/lib/lp/code/model/tests/test_diff.py
+++ b/lib/lp/code/model/tests/test_diff.py
@@ -482,14 +482,14 @@ class TestPreviewDiff(DiffTestCase):
         )
         self.assertEqual("rev-a into rev-b", preview.title)
         # Revision number is used only when it (sequence) is defined.
-        source_rev.sequence = 10
+        removeSecurityProxy(source_rev).sequence = 10
         self.assertEqual("r10 into rev-b", preview.title)
         # Same behavior is applied to the target_branch information.
         target_rev = self.factory.makeBranchRevision(
             branch=mp.target_branch, revision_id="rev-b", sequence=None
         )
         self.assertEqual("r10 into rev-b", preview.title)
-        target_rev.sequence = 1
+        removeSecurityProxy(target_rev).sequence = 1
         self.assertEqual("r10 into r1", preview.title)
 
     def test_title_git(self):
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 40a959c..3df643f 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -2038,7 +2038,7 @@ class LaunchpadObjectFactory(ObjectFactory):
             parent_ids=parent_ids,
             revision_date=revision_date,
         )
-        return branch.createBranchRevision(sequence, revision)
+        return ProxyFactory(branch.createBranchRevision(sequence, revision))
 
     def makeGitRepository(
         self,