From a9a8213731094e112a25d32211271942dc8df023 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Wed, 25 Nov 2020 07:28:10 +0100 Subject: [PATCH 1/2] bimtester: comments and code formating --- src/ifcbimtester/run.py | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/ifcbimtester/run.py b/src/ifcbimtester/run.py index 0673dec275..1f0e7b0bde 100644 --- a/src/ifcbimtester/run.py +++ b/src/ifcbimtester/run.py @@ -1,11 +1,11 @@ -from behave.__main__ import main as behave_main import behave.formatter.pretty # Needed for pyinstaller to package it -import os -import sys -import shutil -import webbrowser import fileinput +import os +import shutil +import sys import tempfile +import webbrowser +from behave.__main__ import main as behave_main # get bimtester source code module path @@ -30,7 +30,12 @@ def run_tests(args): if args["advanced_arguments"]: behave_args.extend(args["advanced_arguments"].split()) elif not args["console"]: - behave_args.extend(["--format", "json.pretty", "--outfile", "report/report.json"]) + behave_args.extend([ + "--format", + "json.pretty", + "--outfile", + "report/report.json" + ]) behave_main(behave_args) print("# All tests are finished.") return True @@ -43,7 +48,13 @@ def get_features(args): if f.endswith(".feature"): os.remove(os.path.join(features_dir, f)) if args["feature"]: - shutil.copyfile(args["feature"], os.path.join(get_resource_path("features"), os.path.basename(args["feature"]))) + shutil.copyfile( + args["feature"], + os.path.join( + get_resource_path("features"), + os.path.basename(args["feature"]) + ) + ) return True if os.path.exists("features"): shutil.copytree("features", get_resource_path("features")) @@ -55,7 +66,10 @@ def get_features(args): if args["feature"] and args["feature"] != f: continue has_features = True - shutil.copyfile(f, os.path.join(get_resource_path("features"), os.path.basename(f))) + shutil.copyfile( + f, + os.path.join(get_resource_path("features"), os.path.basename(f)) + ) return has_features @@ -66,7 +80,8 @@ def get_features(args): # on each new run, directory will be deleted before each new run # https://github.com/behave/behave/issues/871 # run bimtester -# copy manually this code, run bimtester again, does not work on two directories +# copy manually this code, run bimtester again, +# does not work on two directories from behave.runner_util import reset_runtime reset_runtime() @@ -217,9 +232,13 @@ def run_intmp_tests(args={}): behave_args.extend(args["advanced_arguments"].split()) elif "console" not in args: behave_args.extend([ + # redirect prints in step methods + # if step fails some output is catched, thus might not be printed "--no-capture", + # next two lines are one arg "--format", "json.pretty", + # next two lines are one arg "--outfile", os.path.join(report_path, "report.json") ]) From a5b00f1ac99a647aa255ef4450043b7688806bc6 Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Wed, 25 Nov 2020 07:29:10 +0100 Subject: [PATCH 2/2] bimtester: pass the ifc base file name to behave --- src/ifcbimtester/run.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ifcbimtester/run.py b/src/ifcbimtester/run.py index 1f0e7b0bde..c64c54372f 100644 --- a/src/ifcbimtester/run.py +++ b/src/ifcbimtester/run.py @@ -240,7 +240,10 @@ def run_intmp_tests(args={}): "json.pretty", # next two lines are one arg "--outfile", - os.path.join(report_path, "report.json") + os.path.join(report_path, "report.json"), + # next two lines are one arg + "--define", + "ifcbasename={}".format(os.path.splitext(ifc_filename)[0]) ]) print(behave_args)