tests/misc.py

changeset 145
fde18c4d6784
parent 105
43c367c8895b
equal deleted inserted replaced
144:eb4c767522ac 145:fde18c4d6784
12 def colours_test(model): 12 def colours_test(model):
13 ''' Checks that all colours used in the part model are valid. ''' 13 ''' Checks that all colours used in the part model are valid. '''
14 from collections import defaultdict 14 from collections import defaultdict
15 bad_colours = defaultdict(lambda: {'count': 0, 'first-occurrence': None}) 15 bad_colours = defaultdict(lambda: {'count': 0, 'first-occurrence': None})
16 for element in model.body: 16 for element in model.body:
17 if hasattr(element, 'colour') and not element.colour.is_valid: 17 if hasattr(element, 'colour') and not model.context.is_valid_colour(element.colour):
18 bad_colours[element.colour.index]['count'] += 1 18 bad_colours[element.colour.index]['count'] += 1
19 if not bad_colours[element.colour.index]['first-occurrence']: 19 if not bad_colours[element.colour.index]['first-occurrence']:
20 bad_colours[element.colour.index]['first-occurrence'] = element 20 bad_colours[element.colour.index]['first-occurrence'] = element
21 yield from [ 21 yield from [
22 report_problem( 22 report_problem(

mercurial