Randomize results of git cl owners

git cl owners orders owners by score with alphabetization being the tie
breaker. This leads to some owners being suggested far more often than
others.

Adding a tiny amount of randomization to the scoring leads to an even
distribution of equally qualified reviewers. Less qualified reviewers
will still be sorted into distinct buckets - the randomness is too small
to do anything except break ties.

The tests were updated so that they can tolerate the randomness, but
only for breaking ties.

Bug: 1024083
Change-Id: If7d39d1b3bbd980b80b46ab3f62c65215309bdc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1913642
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/owners.py b/owners.py
index 7fa69e3..1a2a1ab 100644
--- a/owners.py
+++ b/owners.py
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-"""A database of OWNERS files.
+r"""A database of OWNERS files.
 
 OWNERS files indicate who is allowed to approve changes in a specific directory
 (or who is allowed to make changes without needing approval of another OWNER).
@@ -62,6 +62,12 @@
 import random
 import re
 
+try:
+  # This fallback applies for all versions of Python before 3.3
+  import collections.abc as collections_abc
+except ImportError:
+  import collections as collections_abc
+
 
 # If this is present by itself on a line, this means that everyone can review.
 EVERYONE = '*'
@@ -80,9 +86,9 @@
   assert not isinstance(obj, str)
   # Module 'collections' has no 'Iterable' member
   # pylint: disable=no-member
-  if hasattr(collections, 'Iterable') and hasattr(collections, 'Sized'):
-    assert (isinstance(obj, collections.Iterable) and
-            isinstance(obj, collections.Sized))
+  if hasattr(collections_abc, 'Iterable') and hasattr(collections_abc, 'Sized'):
+    assert (isinstance(obj, collections_abc.Iterable) and
+            isinstance(obj, collections_abc.Sized))
 
 
 class SyntaxErrorInOwnersFile(Exception):