1- # (C) British Crown Copyright 2010 - 2017 , Met Office 
1+ # (C) British Crown Copyright 2010 - 2019 , Met Office 
22# 
33# This file is part of Iris. 
44# 
2929import  sys 
3030
3131
32- def  failed_images_html ():
33-     """ 
34-     Generates HTML which shows the image failures side-by-side 
35-     when viewed in a web browser. 
36-     """ 
37-     from  iris .tests .idiff  import  step_over_diffs 
38- 
39-     data_uri_template  =  '<img alt="{alt}" src="data:image/png;base64,{img}">' 
40- 
41-     def  image_as_base64 (fname ):
42-         with  open (fname , "rb" ) as  fh :
43-             return  fh .read ().encode ("base64" ).replace ("\n " , "" )
44- 
45-     html  =  ['<!DOCTYPE html>' , '<html>' , '<body>' ]
46-     rdir  =  os .path .join (os .path .dirname (__file__ ), os .path .pardir ,
47-                         'result_image_comparison' )
48-     if  not  os .access (rdir , os .W_OK ):
49-         rdir  =  os .path .join (os .getcwd (), 'iris_image_test_output' )
50- 
51-     for  expected , actual , diff  in  step_over_diffs (rdir , 'similar' , False ):
52-         expected_html  =  data_uri_template .format (
53-             alt = 'expected' , img = image_as_base64 (expected ))
54-         actual_html  =  data_uri_template .format (
55-             alt = 'actual' , img = image_as_base64 (actual ))
56-         diff_html  =  data_uri_template .format (
57-             alt = 'diff' , img = image_as_base64 (diff ))
58- 
59-         html .extend ([expected , '<br>' ,
60-                      expected_html , actual_html , diff_html ,
61-                      '<br><hr>' ])
62- 
63-     html .extend (['</body>' , '</html>' ])
64-     return  '\n ' .join (html )
65- 
66- 
6732# NOTE: Do not inherit from object as distutils does not like it. 
6833class  TestRunner ():
6934    """Run the Iris tests under nose and multiprocessor for performance""" 
@@ -84,12 +49,9 @@ class TestRunner():
8449        ('num-processors=' , 'p' , 'The number of processors used for running ' 
8550                                 'the tests.' ),
8651        ('create-missing' , 'm' , 'Create missing test result files.' ),
87-         ('print-failed-images' , 'f' , 'Print HTML encoded version of failed ' 
88-                                      'images.' ),
8952    ]
9053    boolean_options  =  ['no-data' , 'system-tests' , 'stop' , 'example-tests' ,
91-                        'default-tests' , 'coding-tests' , 'create-missing' ,
92-                        'print-failed-images' ]
54+                        'default-tests' , 'coding-tests' , 'create-missing' ]
9355
9456    def  initialize_options (self ):
9557        self .no_data  =  False 
@@ -100,7 +62,6 @@ def initialize_options(self):
10062        self .coding_tests  =  False 
10163        self .num_processors  =  None 
10264        self .create_missing  =  False 
103-         self .print_failed_images  =  False 
10465
10566    def  finalize_options (self ):
10667        # These enviroment variables will be propagated to all the 
@@ -185,6 +146,4 @@ def run(self):
185146            #   word Mixin. 
186147            result  &=  nose .run (argv = args )
187148        if  result  is  False :
188-             if  self .print_failed_images :
189-                 print (failed_images_html ())
190149            exit (1 )
0 commit comments