def shardingRangeTestHelper(self, total_shards, num_tests): shard_ranges = [] for shard_index in xrange(0, total_shards): shard_ranges.append(run_browser_tests._TestRangeForShard( total_shards, shard_index, num_tests)) # Make assertions about ranges num_tests_run = 0 for i in xrange(0, len(shard_ranges)): cur_range = shard_ranges[i] if i < num_tests: self.assertGreater(cur_range[1], cur_range[0]) num_tests_run += (cur_range[1] - cur_range[0]) else: # Not enough tests to go around all of the shards. self.assertEquals(cur_range[0], cur_range[1]) # Make assertions about non-overlapping ranges for i in xrange(1, len(shard_ranges)): prev_range = shard_ranges[i - 1] cur_range = shard_ranges[i] self.assertEquals(prev_range[1], cur_range[0]) # Assert that we run all of the tests (very important) self.assertEquals(num_tests_run, num_tests)