added check for invalid colours

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

author
Santeri Piippo
date
Mon, 22 Jan 2018 21:04:53 +0200
changeset 25
8990ac138cc2
parent 24
f8080ffceaa9
child 26
7c263b864371

added check for invalid colours

tests/misc.py file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/misc.py	Mon Jan 22 21:04:53 2018 +0200
@@ -0,0 +1,20 @@
+from testsuite import warning
+
+def colours_test(model):
+    yield from (
+        warning(element, 'bad-colour', colour_index = element.colour.index)
+        for element in model.body
+        if hasattr(element, 'colour') and not element.colour.is_valid
+    ) 
+
+manifest = {
+    'tests': {
+        'colour-validity': colours_test,
+    },
+    'messages': {
+        'bad-colour': lambda colour_index: str.format(
+            'invalid colour {}',
+            colour_index,
+        ),
+    },
+}

mercurial