From b65e92a1e050670b75b5ec6f42c6c4d5c304bf70 Mon Sep 17 00:00:00 2001 From: bikegeek Date: Thu, 17 Feb 2022 11:52:12 -0700 Subject: [PATCH] #140 modifications to order of tests and skip image testing to allow proper cleanup. Image test is not a reliable way to test if the generated image matches to an expected image due to differences between machines --- test/wind_rose/test_wind_rose.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/test/wind_rose/test_wind_rose.py b/test/wind_rose/test_wind_rose.py index ec247360..3bcc0b25 100644 --- a/test/wind_rose/test_wind_rose.py +++ b/test/wind_rose/test_wind_rose.py @@ -18,7 +18,7 @@ def setup(): cleanup() # Set up the METPLOTPY_BASE so that met_plot.py will correctly find # the config directory containing all the default config files. - os.environ['METPLOTPY_BASE'] = "../../metplotpy" + os.environ['METPLOTPY_BASE'] = "../../" custom_config_filename = "./wind_rose_custom.yaml" # Invoke the command to generate a Wind rose Diagram based on @@ -51,15 +51,6 @@ def test_files_exist(setup, test_input, expected): cleanup() -def test_images_match(setup): - ''' - Compare an expected plot with the - newly created plot to verify that the plot hasn't - changed in appearance. - ''' - comparison = CompareImages('./wind_rose_expected.png', './wind_rose_default.png') - assert comparison.mssim == 1 - cleanup() @pytest.mark.parametrize("test_input,expected", (["./intermed_files/wind_rose_custom_points.png", True], ["./intermed_files/point_stat_mpr.points1", True])) @@ -68,7 +59,7 @@ def test_points1_files_exist( test_input, expected): Checking that the plot file and points1 file are getting created where expected plot and point file are being saved in the intermed_files subdir ''' - os.environ['METPLOTPY_BASE'] = "../../metplotpy" + os.environ['METPLOTPY_BASE'] = "../../" custom_config_filename = "wind_rose_custom_points.yaml" try: os.mkdir(os.path.join(os.getcwd(), './intermed_files')) @@ -82,6 +73,7 @@ def test_points1_files_exist( test_input, expected): assert os.path.isfile(test_input) == expected # remove the plot and points1 files that were created + cleanup() try: path = os.getcwd() subdir = os.path.join(path, 'intermed_files') @@ -105,7 +97,7 @@ def test_points1_files_exist(test_input, expected): plot and point file are being saved in the intermed_files subdir. Verify that when no stat_file is specified, the point_stat_mpr.txt in the test dir is being used. ''' - os.environ['METPLOTPY_BASE'] = "../../metplotpy" + os.environ['METPLOTPY_BASE'] = "../../" custom_config_filename = "wind_rose_custom2_points.yaml" try: os.mkdir(os.path.join(os.getcwd(), './intermed_files')) @@ -119,6 +111,7 @@ def test_points1_files_exist(test_input, expected): assert os.path.isfile(test_input) == expected # remove the plot and points1 files that were created + cleanup() try: path = os.getcwd() subdir = os.path.join(path, 'intermed_files') @@ -131,4 +124,14 @@ def test_points1_files_exist(test_input, expected): # Typically when files have already been removed or # don't exist. Ignore. pass - + +@pytest.mark.skip("unreliable sometimes fails due to differences in machines.") +def test_images_match(setup): + ''' + Compare an expected plot with the + newly created plot to verify that the plot hasn't + changed in appearance. + ''' + comparison = CompareImages('./wind_rose_expected.png', './wind_rose_default.png') + assert comparison.mssim == 1 + cleanup()