tests/misc.py

Mon, 22 Jan 2018 21:04:53 +0200

author
Santeri Piippo
date
Mon, 22 Jan 2018 21:04:53 +0200
changeset 25
8990ac138cc2
child 26
7c263b864371
permissions
-rw-r--r--

added check for invalid colours

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):
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
4 yield from (
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
5 warning(element, 'bad-colour', colour_index = element.colour.index)
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
6 for element in model.body
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
7 if hasattr(element, 'colour') and not element.colour.is_valid
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
8 )
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
9
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
10 manifest = {
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
11 'tests': {
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
12 'colour-validity': colours_test,
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
13 },
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
14 'messages': {
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
15 'bad-colour': lambda colour_index: str.format(
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
16 'invalid colour {}',
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
17 colour_index,
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
18 ),
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
19 },
8990ac138cc2 added check for invalid colours
Santeri Piippo
parents:
diff changeset
20 }

mercurial