Skip to content

Commit 3b9dbe0

Browse files
committed
Reduce the amount of prints in tests
1 parent 72d99b7 commit 3b9dbe0

5 files changed

Lines changed: 6 additions & 16 deletions

File tree

tests/test_rules/test_chamberlin_courant.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ class TestChamberlinCourant(TestCase):
1111
def test_cc_on_random_instance(self):
1212
for _ in range(50):
1313
profile = get_random_profile(50, 100)
14-
print(f"Computing CC on randomly generated instance: {profile}")
1514
max_size = random.randint(1, len(profile.alternatives))
1615
res = chamberlin_courant(profile, max_size, resoluteness=True)
17-
self.assertLessEqual(len(res), max_size)
16+
self.assertLessEqual(len(res), max_size, f"Failure with CC on: {profile}, k={max_size}")
1817

1918
def test_cc_on_trivial_instances(self):
2019
# Empty profile

tests/test_rules/test_on_abcvoting_instances.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ def process_yaml_file(yaml_file_path: str):
128128
profile_raw = parse_abcvoting_yaml(yaml_file_path)
129129

130130
for profile in [profile_raw, profile_raw.as_multiprofile()]:
131-
print(
132-
f"Testing on {os.path.basename(yaml_file_path)}: {len(profile.alternatives)} alternatives and {profile.num_ballots()} voters"
133-
)
134-
135131
expected_result = read_abcvoting_expected_result(yaml_file_path, profile)
136132

137133
for rule_id, rules in RULE_MAPPING.items():
@@ -148,7 +144,7 @@ def process_yaml_file(yaml_file_path: str):
148144
selection.selected, profile
149145
)
150146
# print("\t", "R", selection_repr, potential_results_repr)
151-
assert selection_repr in potential_results_repr
147+
assert selection_repr in potential_results_repr, f"Failure on {os.path.basename(yaml_file_path)} (m={len(profile.alternatives)}, n={profile.num_ballots()}) with resolute {rule.__name__}: {selection_repr} not in {potential_results_repr}"
152148
except NotImplementedError:
153149
pass
154150

@@ -160,7 +156,7 @@ def process_yaml_file(yaml_file_path: str):
160156
[s.selected for s in selections], profile
161157
)
162158
# print("\t", "IR", selections_repr, potential_results_repr)
163-
assert selections_repr == potential_results_repr
159+
assert selections_repr == potential_results_repr, f"Failure on {os.path.basename(yaml_file_path)} (m={len(profile.alternatives)}, n={profile.num_ballots()}) with resolute {rule.__name__}: {selections_repr} != {potential_results_repr}"
164160
except NotImplementedError:
165161
pass
166162

tests/test_rules/test_phragmen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ class TestPhragmen(TestCase):
1515
def test_phragmen_on_random_instance(self):
1616
for _ in range(50):
1717
profile = get_random_profile(50, 100)
18-
print(f"Computing Phragmén on randomly generated instance: {profile}")
1918
max_size = random.randint(1, len(profile.alternatives))
2019
res = sequential_phragmen(profile, max_size, resoluteness=True)
21-
self.assertLessEqual(len(res), max_size)
20+
self.assertLessEqual(len(res), max_size, f"Failure with Phragmén on: {profile}, k={max_size}")
2221

2322
def test_phragmen_on_trivial_instances(self):
2423
# Empty profile

tests/test_rules/test_tax_rules.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ class TestMES(TestCase):
3131
def test_tax_rules_on_random_instance(self):
3232
for _ in range(50):
3333
profile = get_random_profile(50, 100)
34-
print(f"Computing Tax MES on randomly generated instance: {profile}")
3534
max_size = random.randint(1, len(profile.alternatives))
3635
for rule in tax_rules(max_size):
3736
res = rule(profile, max_size, resoluteness=True)
38-
self.assertLessEqual(len(res), max_size)
37+
self.assertLessEqual(len(res), max_size, f"Failure with Tax MES on: {profile}, k={max_size}")
3938

4039
def test_tax_rules_on_trivial_instances(self):
4140
for rule in tax_rules(0):

tests/test_rules/test_thiele_sequential.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ def test_seq_pav_on_random_instance(self):
2525
PAVScoreHervouin2025,
2626
]:
2727
profile = get_random_profile(20, 50)
28-
print(
29-
f"Computing Sequential PAV with {score.__name__} on randomly generated instance: {profile}"
30-
)
3128
max_size = random.randint(1, len(profile.alternatives))
3229
res = sequential_thiele(profile, max_size, score, resoluteness=True)
33-
self.assertLessEqual(len(res), max_size)
30+
self.assertLessEqual(len(res), max_size, f"Failure with Sequential PAV[{score.__name__}] on: {profile}, k={max_size}")
3431

3532
def test_seq_pav_on_trivial_instances(self):
3633
for score in [

0 commit comments

Comments
 (0)