Commits

Takeshi Nakazato authored 1dc77506e61
CAS-13713 turning precondition into assertion

NAOJ code review #2427

casatasks/tests/tasks/test_task_sdatmcor.py

Modified
528 528 else:
529 529 os.environ['OMP_NUM_THREADS'] = str(omp_num_threads_org)
530 530
531 531 # consistency check
532 532 if omp_num_threads_org is None:
533 533 self.assertIsNone(os.environ.get('OMP_NUM_THREADS'))
534 534 else:
535 535 self.assertEqual(os.environ.get('OMP_NUM_THREADS'), str(omp_num_threads_org))
536 536
537 537 # check log
538 - if os.path.exists(casalog.logfile()):
539 - with open(casalog.logfile(), 'r') as f:
540 - pattern = re.compile(r'.*Setting numThreads_ to ([0-9+])')
541 - lines = list(filter(lambda x: x is not None, map(lambda x: re.search(pattern, x), f)))
542 - num_threads_log = int(lines[-1].group(1))
543 -
544 - print(f'{OMP_NUM_THREADS_INITIAL} {omp_num_threads_org} {num_threads} {num_threads_log}')
545 - self.assertEqual(num_threads, num_threads_log)
538 + self.assertTrue(os.path.exists(casalog.logfile()), msg='casalog file is missing!')
539 + with open(casalog.logfile(), 'r') as f:
540 + pattern = re.compile(r'.*Setting numThreads_ to ([0-9+])')
541 + lines = list(filter(lambda x: x is not None, map(lambda x: re.search(pattern, x), f)))
542 + num_threads_log = int(lines[-1].group(1))
543 +
544 + print(f'{OMP_NUM_THREADS_INITIAL} {omp_num_threads_org} {num_threads} {num_threads_log}')
545 + self.assertEqual(num_threads, num_threads_log)
546 546
547 547 # check output MS
548 548 self.check_result({19: True, 23: True})
549 549
550 550
551 551 class ATMParamTest(unittest.TestCase):
552 552 def _param_test_template(self, valid_test_cases,
553 553 invalid_user_input, user_default, task_default, unit=''):
554 554 # internal error
555 555 wrong_task_default = 'NG'

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

Add shortcut