Skip to content

Commit 3308c5e

Browse files
committed
assert messages
Change-Id: I7a78669ee18d47a4e909783663c2da210d1db699
1 parent 1514b20 commit 3308c5e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

recirq/algorithmic_benchmark_library_test.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
@pytest.mark.parametrize('algo', BENCHMARKS)
1313
def test_domain(algo):
1414
# By convention, the domain should be a recirq module.
15-
assert algo.domain.startswith('recirq.')
15+
assert algo.domain.startswith('recirq.'), 'domain should be a recirq module.'
1616
mod = import_module(algo.domain)
17-
assert isinstance(mod, ModuleType)
17+
assert isinstance(mod, ModuleType), 'domain should be a recirq module.'
1818

1919

2020
def test_benchmark_name_unique_in_domain():
@@ -26,24 +26,30 @@ def test_benchmark_name_unique_in_domain():
2626
@pytest.mark.parametrize('algo', BENCHMARKS)
2727
def test_executable_family_is_formulaic(algo):
2828
# Check consistency in the AlgorithmicBenchmark dataclass:
29-
assert algo.executable_family == algo.spec_class.executable_family
29+
assert algo.executable_family == algo.spec_class.executable_family, \
30+
"benchmark's executable_family should match that of the spec_class"
3031

3132
# By convention, we set this to be the module name. By further convention,
3233
# {algo.domain}.{algo.name} should be the module name.
33-
assert algo.executable_family == f'{algo.domain}.{algo.name}'
34+
assert algo.executable_family == f'{algo.domain}.{algo.name}', \
35+
"The executable family should be set to the benchmarks's domain.name"
3436

3537
# Check the convention that it should give a module
3638
mod = import_module(algo.executable_family)
37-
assert isinstance(mod, ModuleType)
39+
assert isinstance(mod, ModuleType), \
40+
"The executable family should specify an importable module."
3841

3942

4043
@pytest.mark.parametrize('algo', BENCHMARKS)
4144
def test_classes_and_funcs(algo):
4245
# The various class objects should exist in the module
4346
mod = import_module(algo.executable_family)
44-
assert algo.spec_class == getattr(mod, algo.spec_class.__name__)
45-
assert algo.data_class == getattr(mod, algo.data_class.__name__)
46-
assert algo.executable_generator_func == getattr(mod, algo.executable_generator_func.__name__)
47+
assert algo.spec_class == getattr(mod, algo.spec_class.__name__), \
48+
"The spec_class must exist in the benchmark's module"
49+
assert algo.data_class == getattr(mod, algo.data_class.__name__), \
50+
"The data_class must exist in the benchmark's module"
51+
assert algo.executable_generator_func == getattr(mod, algo.executable_generator_func.__name__), \
52+
"the executable_generator_func must exist in the benchmark's module"
4753

4854

4955
def test_globally_unique_executable_family():
@@ -62,7 +68,8 @@ def test_gen_script(algo_config):
6268
algo, config = algo_config
6369

6470
# Make sure it's formulaic
65-
assert config.gen_script == f'gen-{config.short_name}.py'
71+
assert config.gen_script == f'gen-{config.short_name}.py', \
72+
"The gen_script should be of the form 'gen-{short_name}'"
6673

6774
# Make sure it exists
6875
gen_script_path = (f"{RECIRQ_DIR}/{algo.domain.replace('.', '/')}/"

0 commit comments

Comments
 (0)