added more tests

Fri, 18 Sep 2020 20:32:42 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 18 Sep 2020 20:32:42 +0300
changeset 122
116a81996832
parent 121
35b95d1806c9
child 123
0557709c25ec

added more tests

ldcheck.py file | annotate | diff | comparison | revisions
reference/colors.ldr file | annotate | diff | comparison | revisions
unittest.py file | annotate | diff | comparison | revisions
unittests/colors.test file | annotate | diff | comparison | revisions
unittests/skew.test file | annotate | diff | comparison | revisions
webfront.py file | annotate | diff | comparison | revisions
--- a/ldcheck.py	Fri Sep 18 20:26:19 2020 +0300
+++ b/ldcheck.py	Fri Sep 18 20:32:42 2020 +0300
@@ -29,6 +29,7 @@
     if config != read_config:
         config.write()
     check_library_paths(config)
+    load_ldconfig_ldr(config)
     return config
 
 def library_paths(config):
@@ -86,6 +87,11 @@
             ))
         exit(0)
 
+def load_ldconfig_ldr(config):
+    for ldconfig_ldr_path in find_ldconfig_ldr_paths(config):
+        with ldconfig_ldr_path.open() as ldconfig_ldr:
+            load_colours(ldconfig_ldr)
+
 def format_report(report, model, test_suite, *, use_colors = True):
     from testsuite import problem_text
     messages = []
@@ -145,9 +151,6 @@
     )
     args = parser.parse_args()
     config = load_config()
-    for ldconfig_ldr_path in find_ldconfig_ldr_paths(config):
-        with ldconfig_ldr_path.open() as ldconfig_ldr:
-            load_colours(ldconfig_ldr)
     if args.color:
         try:
             import colorama
--- a/reference/colors.ldr	Fri Sep 18 20:26:19 2020 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-4 24 0 0 0 1 0 0 1 1 0 0 1 0
-2 4 0 0 0 1 0 0
-4 123 0 0 0 1 0 0 1 1 0 0 1 0
--- a/unittest.py	Fri Sep 18 20:26:19 2020 +0300
+++ b/unittest.py	Fri Sep 18 20:32:42 2020 +0300
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 from ldcheck import appname, version, version_string
-from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths
+from ldcheck import load_config, find_ldconfig_ldr_paths
 from ldcheck import script_directory
 from pathlib import Path
 from parse import read_ldraw
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unittests/colors.test	Fri Sep 18 20:32:42 2020 +0300
@@ -0,0 +1,5 @@
+0 Testing: bad-colour bad-colour-24-line bad-colour-24-nonline
+0 Expecting: bad-colour-24-nonline:1 bad-colour-24-line:2 bad-colour:3
+4 24 0 0 0 1 0 0 1 1 0 0 1 0
+2 4 0 0 0 1 0 0
+4 123 0 0 0 1 0 0 1 1 0 0 1 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/unittests/skew.test	Fri Sep 18 20:32:42 2020 +0300
@@ -0,0 +1,4 @@
+0 Testing: skew-major
+0 Expecting: skew-major:1 skew-major:2
+4 16 25 0 -5 25 0 -15 35 0 -15 35 5 -5
+4 16 40 0 -5 40 0 -15 50 5 -15 50 0 -5
--- a/webfront.py	Fri Sep 18 20:26:19 2020 +0300
+++ b/webfront.py	Fri Sep 18 20:32:42 2020 +0300
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 from flask import Flask, render_template, redirect, request
 from ldcheck import appname, version, version_string
-from ldcheck import load_config, load_colours, find_ldconfig_ldr_paths
+from ldcheck import load_config, find_ldconfig_ldr_paths
 from parse import read_ldraw
 from testsuite import load_tests, check_model, problem_text, all_problem_types
 
@@ -37,10 +37,7 @@
             return redirect(request.url)
         file = request.files['file']
         filename = file.filename
-        config = load_config('ldcheck.cfg')
-        for ldconfig_ldr_path in find_ldconfig_ldr_paths(config):
-            with ldconfig_ldr_path.open() as ldconfig_ldr:
-                load_colours(ldconfig_ldr)
+        config = load_config()
         model = read_ldraw(
             file.stream,
             name = filename,

mercurial