Skip to content

Commit

Permalink
#140 modifications to order of tests and skip image testing to allow …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
bikegeek committed Feb 17, 2022
1 parent 728b2e0 commit b65e92a
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions test/wind_rose/test_wind_rose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]))
Expand All @@ -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'))
Expand All @@ -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')
Expand All @@ -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'))
Expand All @@ -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')
Expand All @@ -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()

0 comments on commit b65e92a

Please sign in to comment.