12
12
@pytest .mark .parametrize ('algo' , BENCHMARKS )
13
13
def test_domain (algo ):
14
14
# 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.'
16
16
mod = import_module (algo .domain )
17
- assert isinstance (mod , ModuleType )
17
+ assert isinstance (mod , ModuleType ), 'domain should be a recirq module.'
18
18
19
19
20
20
def test_benchmark_name_unique_in_domain ():
@@ -26,24 +26,30 @@ def test_benchmark_name_unique_in_domain():
26
26
@pytest .mark .parametrize ('algo' , BENCHMARKS )
27
27
def test_executable_family_is_formulaic (algo ):
28
28
# 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"
30
31
31
32
# By convention, we set this to be the module name. By further convention,
32
33
# {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"
34
36
35
37
# Check the convention that it should give a module
36
38
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."
38
41
39
42
40
43
@pytest .mark .parametrize ('algo' , BENCHMARKS )
41
44
def test_classes_and_funcs (algo ):
42
45
# The various class objects should exist in the module
43
46
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"
47
53
48
54
49
55
def test_globally_unique_executable_family ():
@@ -62,7 +68,8 @@ def test_gen_script(algo_config):
62
68
algo , config = algo_config
63
69
64
70
# 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}'"
66
73
67
74
# Make sure it exists
68
75
gen_script_path = (f"{ RECIRQ_DIR } /{ algo .domain .replace ('.' , '/' )} /"
0 commit comments