Commits
Kumar Golap authored fa297cc1413 Merge
15 15 | # |
16 16 | # |
17 17 | # Based on the requirements listed in casadocs found here: |
18 18 | # https://casadocs.readthedocs.io/en/stable/api/tt/casatasks.visualization.plotprofilemap.html |
19 19 | # |
20 20 | ########################################################################## |
21 21 | import os |
22 22 | import shutil |
23 23 | import numpy |
24 24 | import re |
25 - | import imghdr |
25 + | import subprocess |
26 26 | import unittest |
27 27 | import matplotlib |
28 28 | import pylab as pl |
29 29 | |
30 30 | from casatasks import plotprofilemap |
31 31 | from casatasks import exportfits |
32 32 | from casatools import image |
33 33 | from casatools import regionmanager |
34 34 | from casatools import ctsys |
35 35 | |
284 284 | print('verifying plotmasked parameter: axes {0} plotmasked {1}'.format(index, plotmasked)) |
285 285 | # verify plotmasked parameter |
286 286 | self._verify_plotmasked(a, plotmasked) |
287 287 | index += 1 |
288 288 | |
289 289 | def verify_figfile(self, figfile): |
290 290 | # figfile must exist |
291 291 | self.assertTrue(os.path.exists(figfile)) |
292 292 | |
293 293 | # figfile must be PNG format |
294 - | self.assertEqual(imghdr.what(figfile), 'png') |
294 + | cmd_output = subprocess.getoutput(f'file {figfile}') |
295 + | # output must be single line |
296 + | lines = cmd_output.rstrip('\n').split('\n') |
297 + | self.assertEqual(len(lines), 1) |
298 + | # output must be in "filename: file info" format |
299 + | items = lines[0].split(': ') |
300 + | self.assertEqual(len(items), 2) |
301 + | file_type = items[1] |
302 + | self.assertTrue(file_type.startswith('PNG image data')) |
295 303 | |
296 304 | def skip_if_darwin(self): |
297 305 | sysname = os.uname()[0] |
298 306 | if sysname == 'Darwin': |
299 307 | self.skipTest('Skip test_export_image on OS X since it may cause segfault') |
300 308 | return |
301 309 | |
302 310 | def test_image_not_exist(self): |
303 311 | """test_image_not_exist: input image does not exist (causes error)""" |
304 312 | imagename = 'blabla.im' |