[merge] trivial: make assertSubset use sets
Martin Pool
mbp at sourcefrog.net
Wed Aug 15 04:53:37 BST 2007
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2007-08-15 03:01:38 +0000
+++ bzrlib/tests/__init__.py 2007-08-15 03:42:22 +0000
@@ -900,12 +900,9 @@
def assertSubset(self, sublist, superlist):
"""Assert that every entry in sublist is present in superlist."""
- missing = []
- for entry in sublist:
- if entry not in superlist:
- missing.append(entry)
+ missing = set(sublist) - set(superlist)
if len(missing) > 0:
- raise AssertionError("value(s) %r not present in container %r" %
+ raise AssertionError("value(s) %r not present in container %r" %
(missing, superlist))
def assertListRaises(self, excClass, func, *args, **kwargs):
This cuts a few seconds off the runtime of the selftest --list-only
tests, and probably also helps others.
--
Martin
More information about the bazaar
mailing list