22
33import os .path
44from os import unlink
5+ from matplotlib .testing .compare import compare_images
56
67
78ROOT = os .path .dirname (os .path .abspath (__file__ )) + "/test_data/"
@@ -26,11 +27,8 @@ def test_correlation_plot_with_minimal_options():
2627 expected = "'bowtie2 test1.bam'\t 1.0000\t 1.0000\n "
2728 assert expected in resp , f"'{ expected } ' not found in '{ resp } '"
2829
29- png_file_size = os .path .getsize (COR_PLOT_1 )
30- expected_file_size = os .path .getsize (out_png )
31- size_tolerance = 5000
32- size_difference = abs (png_file_size - expected_file_size )
33- assert size_difference <= size_tolerance , "File size do not match"
30+ res = compare_images (COR_PLOT_1 , out_png , 50 )
31+ assert res is None , "Plots do not match"
3432 unlink (out_png )
3533
3634
@@ -41,9 +39,7 @@ def test_correlation_plot_scatter():
4139 out_png2 = '/tmp/correlation_plot2.png'
4240 args = "--corData {} -p scatterplot -c pearson -o {}" .format (COR_DATA_IN1 , out_png2 ).split ()
4341 pc .main (args )
44- png_file_size = os .path .getsize (COR_PLOT_2 )
45- expected_file_size = os .path .getsize (out_png2 )
46- size_tolerance = 5000
47- size_difference = abs (png_file_size - expected_file_size )
48- assert size_difference <= size_tolerance , "File size do not match"
42+
43+ res = compare_images (COR_PLOT_2 , out_png2 , 50 )
44+ assert res is None , "Plots do not match"
4945 unlink (out_png2 )
0 commit comments