jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Thread tests: Simplified intersections ......................................................................
[IMPROV] Thread tests: Simplified intersections
Instead of using itertools.product it is using sets and their 'intersection' method.
Change-Id: I162573d122e09aba2b3dd0f2a12f78fb2b3018bf --- M tests/thread_tests.py 1 file changed, 2 insertions(+), 12 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved Mpaa: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/tests/thread_tests.py b/tests/thread_tests.py index 3222a8f..79a67a4 100644 --- a/tests/thread_tests.py +++ b/tests/thread_tests.py @@ -7,12 +7,6 @@ # __version__ = '$Id$'
-import itertools -import sys - -if sys.version_info[0] == 2: - from future_builtins import filter - from tests.aspects import unittest, TestCase from pywikibot.tools import ThreadedGenerator, intersect_generators
@@ -50,17 +44,13 @@ # first otherwise the generator is empty the second time. datasets = [list(gen) for gen in gens]
- itertools_result = set( - [item[0] for item in filter( - lambda lst: all([x == lst[0] for x in lst]), - itertools.product(*datasets)) - ]) + set_result = set(datasets[0]).intersection(*datasets[1:])
result = list(intersect_generators(datasets))
self.assertEqual(len(set(result)), len(result))
- self.assertCountEqual(result, itertools_result) + self.assertCountEqual(result, set_result)
class BasicGeneratorIntersectTestCase(GeneratorIntersectTestCase):