def test_sharding(self):
        tests = [
            'foo/bar.py',
            'foo/baz.py',
            'foo.bar.test_biz',
            'foo.bar.test_buz',
        ]
        test_weights = {
            ('foo', 'bar'): 50,
            ('foo', 'baz'): 15,
            ('foo', 'bar', 'test_biz'): 10,
            ('foo', 'bar', 'test_buz'): 200,
        }
        avg_test_time = len(test_weights) / sum(test_weights.values())

        groups = TestsExpander.shard_tests(tests, 2, test_weights, avg_test_time)
        assert len(groups) == 2
        groups.sort()
        assert groups[0] == (78, ['foo/bar.py', 'foo/baz.py', 'foo.bar.test_biz'])
        assert groups[1] == (201, ['foo.bar.test_buz'])

        groups = TestsExpander.shard_tests(tests, 3, test_weights, avg_test_time)
        assert len(groups) == 3
        groups.sort()
        assert groups[0] == (27, ['foo/baz.py', 'foo.bar.test_biz'])
        assert groups[1] == (51, ['foo/bar.py'])
        assert groups[2] == (201, ['foo.bar.test_buz'])

        # more shards than tests
        groups = TestsExpander.shard_tests(tests, len(tests) * 2, test_weights, avg_test_time)
        assert len(groups) == len(tests)
dataset/ETHPy150Open dropbox/changes/tests/changes/expanders/test_tests.py/TestsExpanderTest.test_sharding/swapped operands of `/`