@@ -136,7 +136,7 @@ def __lt__(self, other):
136
136
return order .index (self .outcome ) < order .index (other .outcome )
137
137
138
138
def create_asset (self , content , extra_index ,
139
- test_index , file_extension ):
139
+ test_index , file_extension , mode = 'w' ):
140
140
hash_key = '' .join ([self .test_id , str (extra_index ),
141
141
str (test_index )]).encode ('utf-8' )
142
142
hash_generator = hashlib .md5 ()
@@ -150,7 +150,7 @@ def create_asset(self, content, extra_index,
150
150
151
151
relative_path = '{0}/{1}' .format ('assets' , asset_file_name )
152
152
153
- with open (asset_path , 'w' ) as f :
153
+ with open (asset_path , mode ) as f :
154
154
f .write (content )
155
155
return relative_path
156
156
@@ -162,12 +162,9 @@ def append_extra_html(self, extra, extra_index, test_index):
162
162
extra .get ('content' ))
163
163
href = '#'
164
164
else :
165
- content = extra .get ('content' )
166
- if PY3 :
167
- content = bytearray (extra .get ('content' ), 'utf-8' )
168
- content = str (b64decode (content ))
165
+ content = b64decode (extra .get ('content' ))
169
166
href = self .create_asset (content , extra_index ,
170
- test_index , 'png' )
167
+ test_index , 'png' , 'wb' )
171
168
image_src = href
172
169
self .additional_html .append (html .div (
173
170
html .a (html .img (src = image_src ), href = href ),
0 commit comments