def test_results_order(self): def func(x): time.sleep(x) return x values = tuple(random.random() * 0.1 for x in range(10)) results = concurrent.tmap(func, values) expected = [concurrent.Result(True, x) for x in values] self.assertEqual(results, expected)
def test_error(self): error = RuntimeError("No result for you!") def func(x): raise error results = concurrent.tmap(func, range(10)) expected = [concurrent.Result(False, error)] * 10 self.assertEqual(results, expected)
def test_error(self): error = RuntimeError("No result for you!") def func(x): raise error # pylint: disable=range-builtin-not-iterating results = concurrent.tmap(func, range(10)) expected = [concurrent.Result(False, error)] * 10 self.assertEqual(results, expected)
def test_errors(self): error = RuntimeError("No result for you!") def func(x): raise error results = list(concurrent.tmap(func, iter(range(10)))) expected = [concurrent.Result(False, error)] * 10 assert results == expected
def test_results(self): values = tuple(range(10)) results = concurrent.tmap(lambda x: x, values) expected = [concurrent.Result(True, x) for x in values] self.assertEqual(results, expected)
def test_results(self): values = tuple(range(10)) results = set(concurrent.tmap(lambda x: x, values)) expected = set(concurrent.Result(True, x) for x in values) assert results == expected