From d53905054facdb67dc5c16e6048d9eccf9e728dd Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Tue, 29 Sep 2020 20:02:31 +0200 Subject: [PATCH] Test PyExamples: comment and simplify check_functionality.py --- .../Python/PyExamples/check_functionality.py | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/Tests/Functional/Python/PyExamples/check_functionality.py b/Tests/Functional/Python/PyExamples/check_functionality.py index a2f9ba3d7b7..067316c751b 100644 --- a/Tests/Functional/Python/PyExamples/check_functionality.py +++ b/Tests/Functional/Python/PyExamples/check_functionality.py @@ -52,32 +52,23 @@ def run_example(filename): if not os.path.exists(filename): raise Exception("Example script '"+filename+"' not found") - print(filename) + print("Input script: "+filename) fig = get_figure(filename) - try: - exec_full(filename) - plot_file_name = os.path.splitext(os.path.basename(filename))[0] + ".png" - plot_file_name = os.path.join(output_dir, plot_file_name) - print(plot_file_name) - plt.savefig(plot_file_name, bbox_inches='tight') - plt.close(fig) + exec_full(filename) - status = "OK" + plot_file_name = os.path.join(output_dir, + os.path.splitext(os.path.basename(filename))[0] + ".png") + print("Output image: "+plot_file_name) + plt.savefig(plot_file_name, bbox_inches='tight') + plt.close(fig) - kb = os.path.getsize(plot_file_name)/1000. - if kb < 4.0: - status = "EMPTY?" - - except: - e = sys.exc_info()[0] - print("Error {0} while trying to execute '{1}'".format(e, filename)) - status = "FAILED" - - print(status) - if status != "OK": - raise Exception(status) + imgSize = os.path.getsize(plot_file_name) + if imgSize == 0: + raise Exception("Image file is empty") + if imgSize < 20000: + raise Exception("Image file is unplausibly small") if __name__ == '__main__': -- GitLab