val_tp: type, msg: str): """Check if result is a dict with keys of type key_tp and values of type list that are non-empty and with elements of type val_tp. """ self.assertTrue(isinstance(result, dict), msg) for (key, val) in result.items(): self.assertTrue(isinstance(key, key_tp), msg) self.assertTrue(isinstance(val, list), msg) # self.assertTrue(val != [], # msg + ' and the values should be non-empty lists') for item in val: self.assertTrue(isinstance(item, val_tp), msg) checker_generic.ensure_no_io('club_functions') TARGET_LEN = 79 print(''.center(TARGET_LEN, "=")) print(' Start: checking coding style '.center(TARGET_LEN, "=")) checker_generic.run_pyta('club_functions.py', 'pyta/a3_pyta.txt') print(' End checking coding style '.center(TARGET_LEN, "=")) print(' Start: checking type contracts '.center(TARGET_LEN, "=")) unittest.main(exit=False) print(' End checking type contracts '.center(TARGET_LEN, "=")) print('\nScroll up to see ALL RESULTS:') print(' - checking coding style') print(' - checking type contract\n')
self.assertTrue(isinstance(result[1][i], int), msg) print(' check complete') def _check_simple_type(self, func: callable, args: list, expected: type) -> None: """Check that func called with arguments args returns a value of type expected. Display the progress and the result of the check. """ print('\nChecking {}...'.format(func.__name__)) result = checker_generic.type_check_simple(func, args, expected) self.assertTrue(result[0], result[1]) print(' check complete') checker_generic.ensure_no_io('elevation') TARGET_LEN = 79 print(''.center(TARGET_LEN, "=")) print(' Start: checking coding style '.center(TARGET_LEN, "=")) checker_generic.run_pyta('elevation.py', 'pyta/a2_pyta.txt') print(' End checking coding style '.center(TARGET_LEN, "=")) print(' Start: checking type contracts '.center(TARGET_LEN, "=")) unittest.main(exit=False) print(' End checking type contracts '.center(TARGET_LEN, "=")) print('\nScroll up to see ALL RESULTS:') print(' - checking coding style') print(' - checking type contract\n')