tests/misc.py

Tue, 23 Jan 2018 15:30:48 +0200

author
Santeri Piippo
date
Tue, 23 Jan 2018 15:30:48 +0200
changeset 30
0d9ca37901ed
parent 26
7c263b864371
child 38
66c9591b733d
permissions
-rw-r--r--

added test for collinearity, fixed bowtie test

25
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
1 from testsuite import warning
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
2
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
3 def colours_test(model):
26
7c263b864371 Added command line option to list all checks.
Santeri Piippo
parents: 25
diff changeset
4 ''' Checks that all colours used in the part model are valid. '''
25
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
5 yield from (
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
6 warning(element, 'bad-colour', colour_index = element.colour.index)
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
7 for element in model.body
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
8 if hasattr(element, 'colour') and not element.colour.is_valid
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
9 )
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
10
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
11 manifest = {
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
12 'tests': {
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
13 'colour-validity': colours_test,
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
14 },
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
15 'messages': {
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
16 'bad-colour': lambda colour_index: str.format(
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
17 'invalid colour {}',
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
18 colour_index,
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
19 ),
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
20 },
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
21 }

mercurial