Skip to content

Commit f68ce35

Browse files
committed
parameterize WeightedMap in test_large_case.py
1 parent 5064e70 commit f68ce35

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/test_large_case.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
'''
2020

2121

22-
@pytest.fixture
23-
def large_one_to_one():
22+
weighted_map_classes = [allocating.ListWeightedMap, allocating.DictWeightedMap]
23+
24+
@pytest.fixture(params=weighted_map_classes)
25+
def large_one_to_one(request):
2426
elements = range(20)
2527
sources = {str(e): 1 for e in elements}
2628
targets = {str(e): 1 for e in elements}
@@ -29,13 +31,13 @@ def large_one_to_one():
2931
wmap_list.append({'from': str(e), 'to': str(e), 'weight': 0})
3032
wmap_list.append({'from': str(e), 'to': str((e + 1) % len(elements)), 'weight': 1})
3133
wmap_list.append({'from': str(e), 'to': str((e - 1) % len(elements)), 'weight': 1})
32-
wmap = allocating.ListWeightedMap(wmap_list)
34+
wmap = request.param(wmap_list)
3335

3436
yield allocating.Allocator(sources, wmap, targets)
3537

3638

37-
@pytest.fixture
38-
def large_one_to_one_alternate():
39+
@pytest.fixture(params=weighted_map_classes)
40+
def large_one_to_one_alternate(request):
3941
elements = range(20)
4042
sources = {str(e): 1 for e in elements}
4143
targets = {str(e): 1 for e in elements}
@@ -44,7 +46,7 @@ def large_one_to_one_alternate():
4446
wmap_list.append({'from': str(e), 'to': str(e), 'weight': 1})
4547
wmap_list.append({'from': str(e), 'to': str((e + 1) % len(elements)), 'weight': 3 * (e % 2)})
4648
wmap_list.append({'from': str(e), 'to': str((e - 1) % len(elements)), 'weight': 2.5})
47-
wmap = allocating.ListWeightedMap(wmap_list)
49+
wmap = request.param(wmap_list)
4850

4951
yield allocating.Allocator(sources, wmap, targets)
5052

0 commit comments

Comments
 (0)