added tests for colour 24 usage

Sun, 23 Jun 2019 00:05:59 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 23 Jun 2019 00:05:59 +0300
changeset 70
2453681c6a69
parent 69
a24c4490d9f2
child 71
4e24867a0110

added tests for colour 24 usage

tests/misc.py file | annotate | diff | comparison | revisions
--- a/tests/misc.py	Sat Jun 22 23:52:08 2019 +0300
+++ b/tests/misc.py	Sun Jun 23 00:05:59 2019 +0300
@@ -128,6 +128,23 @@
                 type = model.header.effective_filetype,
             )
 
+@problem_type('bad-colour-24-nonline',
+    severity = 'hold',
+    message = 'Colour 24 used on non-lines',
+)
+@problem_type('bad-colour-24-line',
+    severity = 'hold',
+    message = 'Line with colour other than 24',
+)
+def colour_24_test(model):
+    for element in model.body:
+        if hasattr(element, 'colour'):
+            is_line = isinstance(element, linetypes.LineSegment)
+            if not is_line and element.colour.index == 24:
+                yield report_problem('bad-colour-24-nonline', bad_object = element)
+            if is_line and element.colour.index != 24:
+                yield report_problem('bad-colour-24-line', bad_object = element)
+
 manifest = {
     'tests': [
         colours_test,
@@ -138,5 +155,6 @@
         unofficiality_test,
         header_bfc_test,
         keywords_tests,
+        colour_24_test,
     ],
 }

mercurial