Commits

David Mehringer authored and Takeshi Nakazato committed 2ca402c80bf Merge
Pull request #625: CAS-13654 add more useful error message

Merge in CASA/casa6 from CAS-13654 to master * commit 'e753e56b4b4f1e157b65f4699eb4c0f2d40dca7f': Added a missing * to identify the bullet element. add another hdkey value to test for verfication of this issue fix error message fix test test more useful error message CAS-13654 add more useful error message
No tags

casatasks/tests/tasks/test_task_imhead.py

Modified
423 423 try:
424 424 self.assertEqual(np.all(x, exp_dict[k]), msg)
425 425 except:
426 426 # string arrays can throw "Cannot reduce flexible type" exceptions
427 427 self.assertEqual(list(x), list(exp_dict[k]), msg)
428 428 else:
429 429 self.assertEqual(x, exp_dict[k], msg)
430 430 # test bogus key fails
431 431 k = 'boguskey'
432 432 self.assertRaises(
433 - Exception, imhead, datacopy, mode='get', hdkey=k,
434 - msg='Incorrectly found bogus key'
433 + Exception, imhead, datacopy, mode='get', hdkey=k,
434 + msg='Incorrectly found bogus key'
435 435 )
436 + # CAS-13654
437 + for k in ('incr', 'axisnames'):
438 + with self.assertRaises(RuntimeError) as cm:
439 + imhead(datacopy, mode='get', hdkey=k)
440 + exc = cm.exception
441 + expected_msg = (
442 + f'Unknown keyword {k}. If you are trying to use a key name '
443 + 'from the imhead summary dictionary, note that some keys in '
444 + 'mode=\'put\'/\'get\' are different from mode=\'summary\'. '
445 + 'Please see imhead description in the CASA online '
446 + 'documentation for complete details.'
447 + )
448 + pos = str(exc).find(expected_msg)
449 + self.assertNotEqual(
450 + pos, -1, msg=f'Unexpected exception was thrown: {exc}'
451 + )
452 +
436 453
437 454 def test_summary(self):
438 455 '''
439 456 test_summary
440 457 -----------------
441 458 '''
442 459 ###NOTE: to test the function of the verbose parameter an image with multiple beams is required
443 460 summaryDictnoV = {
444 461 'axisnames': np.array(['Right Ascension', 'Declination', 'Stokes', 'Frequency'], dtype='<U16'),
445 462 'axisunits': np.array(['rad', 'rad', '', 'Hz'], dtype='<U16'), 'defaultmask': '',

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut