← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-test-publishing-infloop into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-test-publishing-infloop into launchpad:master.

Commit message:
Avoid possible infinite loop in publishing.txt

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

If the list being shuffled to test that ArchiveSourcePublications respects its ordering has length 0 or 1, then random.shuffle will necessarily return the same ordering, so a loop that terminates only when the ordering changes will never terminate.  This can only happen as a result of an earlier failure, but an infinite loop is an unfriendly way to report a test failure.

(This can be simplified when this test is rewritten as a unit test, since unit tests don't barrel onward in the face of failures.)
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-test-publishing-infloop into launchpad:master.
diff --git a/lib/lp/soyuz/doc/publishing.txt b/lib/lp/soyuz/doc/publishing.txt
index 2ae8fcd..1fd1eb5 100644
--- a/lib/lp/soyuz/doc/publishing.txt
+++ b/lib/lp/soyuz/doc/publishing.txt
@@ -1377,7 +1377,8 @@ different, and check if the order is respected:
     >>> shuffled_sources_list = list(cprov_published_sources)
 
     >>> import random
-    >>> while shuffled_sources_list == original_sources_list:
+    >>> while (len(original_sources_list) > 1 and
+    ...        shuffled_sources_list == original_sources_list):
     ...     random.shuffle(shuffled_sources_list)
 
     >>> shuffled_decorated_list = ArchiveSourcePublications(