Skip to content
This repository was archived by the owner on Apr 18, 2018. It is now read-only.

Commit a4c05d5

Browse files
committed
replace assertion with ValueError
If too few or too many values are passed for threshold, the function now produces a helpful error message, rather than raising an assertion error.
1 parent 5d9d832 commit a4c05d5

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

verification/verification_parser.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,21 @@ def verification_parser(filename, threshold):
1111
# how many additional tests are run with tweaks to this configuration
1212
num_exps = len(glob.glob(directory+'/input.*'))+1
1313

14-
assert len(threshold)==num_exps
15-
14+
# check that the correct number of values for `threshold` have been given
15+
if len(threshold) != num_exps:
16+
# some if statements to deal with grammar
17+
if len(threshold)==1:
18+
error_message = '{0} value given for threshold, '.format(len(threshold))
19+
else:
20+
error_message = '{0} values given for threshold, '.format(len(threshold))
21+
22+
if num_exps==1:
23+
error_message = error_message + 'but {0} subtest found.'.format(num_exps)
24+
else:
25+
error_message = error_message + 'but {0} subtests found.'.format(num_exps)
26+
27+
raise ValueError(error_message)
28+
1629
# open the testreport output to assess pass/fail
1730
with open(filename) as f:
1831
lines = f.readlines()

0 commit comments

Comments
 (0)