From 031a0cec5979611e802a83e695fa5f1485df55bf Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 5 Feb 2021 08:30:54 +1100 Subject: [PATCH] Minor fix --- src/ifcbimtester/bimtester/run.py | 10 +++++----- src/ifcbimtester/cli.py | 13 +++++++------ .../blenderbim/bim/module/bimtester/operator.py | 3 ++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ifcbimtester/bimtester/run.py b/src/ifcbimtester/bimtester/run.py index ad41ecfd90..d07b3ef696 100644 --- a/src/ifcbimtester/bimtester/run.py +++ b/src/ifcbimtester/bimtester/run.py @@ -14,14 +14,10 @@ from behave.__main__ import main as behave_main class TestRunner: - def __init__(self, ifc_path, ifc=None, schema=None): + def __init__(self, ifc_path, ifc=None): IfcStore.path = ifc_path IfcStore.file = ifc if ifc else ifcopenshell.open(ifc_path) - if schema: - schema = ifcopenshell.express.parse(path) - ifcopenshell.register_schema(schema) - try: # PyInstaller creates a temp folder and stores path in _MEIPASS self.base_path = sys._MEIPASS @@ -31,6 +27,10 @@ class TestRunner: self.locale_path = os.path.join(self.base_path, "locale") def run(self, args): + if args["schema_file"]: + schema = ifcopenshell.express.parse(args["schema_file"]) + ifcopenshell.register_schema(args["schema_name"]) + tmpdir = tempfile.mkdtemp() features_path = os.path.join(tmpdir, "features") steps_path = os.path.join(features_path, "steps") diff --git a/src/ifcbimtester/cli.py b/src/ifcbimtester/cli.py index 5fff1cb6ce..7c839e64ef 100644 --- a/src/ifcbimtester/cli.py +++ b/src/ifcbimtester/cli.py @@ -11,17 +11,18 @@ parser.add_argument("-a", "--action", type=str, help="Action to perform, from ru parser.add_argument("--advanced-arguments", type=str, help="Specify arguments to Behave", default="") parser.add_argument("-c", "--console", action="store_true", help="Show results in the console") parser.add_argument("-f", "--feature", type=str, help="Specify a feature file to test", required=True) -parser.add_argument("-i", "--ifc", type=str, help="Specify a ifc file", required=True) -parser.add_argument("-p", "--path", type=str, help="Define a path for use in tests") +parser.add_argument("-i", "--ifc", type=str, help="Specify an IFC file to test", required=True) +parser.add_argument("-p", "--path", type=str, help="Define a path for use in test steps that use relative paths") parser.add_argument("-r", "--report", type=str, help="Specify an output file for a HTML report") -parser.add_argument("--steps", type=str, help="Specify custom step definitions") -parser.add_argument("--schema", type=str, help="Specify an output file for a HTML report") -parser.add_argument("--lang", type=str, help="Specify a language", default="") +parser.add_argument("--steps", type=str, help="Specify a custom step definition Python file or directory") +parser.add_argument("--schema-file", type=str, help="Path to a custom IFC schema, used with --schema-name") +parser.add_argument("--schema-name", type=str, help="The name of a custom IFC schema, used with --schema-file") +parser.add_argument("--lang", type=str, help="Specify a language e.g. en/de/fr/it", default="") args = vars(parser.parse_args()) if args["action"] == "run": - report_json = bimtester.run.TestRunner(args["ifc"], schema=args["schema"] or None).run(args) + report_json = bimtester.run.TestRunner(args["ifc"]).run(args) if args["report"]: bimtester.reports.ReportGenerator().generate(report_json, args["report"]) elif args["action"] == "purge": diff --git a/src/ifcblenderexport/blenderbim/bim/module/bimtester/operator.py b/src/ifcblenderexport/blenderbim/bim/module/bimtester/operator.py index 133a44c124..38ba1e11b7 100644 --- a/src/ifcblenderexport/blenderbim/bim/module/bimtester/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/module/bimtester/operator.py @@ -28,7 +28,8 @@ class ExecuteBIMTester(bpy.types.Operator): "ifc": props.ifc_file, "path": "", "report": report, - "schema": "", + "schema_file": "", + "schema_name": "", "lang": "en", "steps": props.steps }