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')
Ejemplo n.º 2
0
        self.assertEqual(tweet.SPACE, ' ',
                         'Set SPACE to its original value: \' \'')
        print('  check complete')

    def _check(self, func: callable, args: list,
               ret_type: type) -> None:
        """Check that func called with arguments args returns a value of type
        ret_type. Display the progress and the result of the check.

        """

        print('\nChecking {}...'.format(func.__name__))
        result = checker_generic.check(func, args, ret_type)
        self.assertTrue(result[0], result[1])
        print('  check complete')


TARGET_LEN = 79
print(''.center(TARGET_LEN, "="))
print(' Start: checking coding style '.center(TARGET_LEN, "="))
checker_generic.run_pyta('tweet.py', 'pyta/a1_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')
Ejemplo n.º 3
0
            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')
Ejemplo n.º 4
0
        self.assertIsInstance(dictionary, dict, error_message)
        for key, poetry_form in dictionary.items():
            self.assertIsInstance(key, str, error_message)
            self.assertIsInstance(poetry_form, tuple, error_message)
            self.assertEqual(len(poetry_form), 2, error_message)
            self.assertIsInstance(poetry_form[0], list, error_message)
            for v in poetry_form[0]:
                self.assertIsInstance(v, int)
            self.assertIsInstance(poetry_form[1], list, error_message)
            for v in poetry_form[1]:
                self.assertIsInstance(v, str)


if __name__ == '__main__':
    TARGET_LEN = 79
    print(''.center(TARGET_LEN, "="))
    print(' Start: checking coding style '.center(TARGET_LEN, "="))
    checker_generic.run_pyta('poetry.py', 'pyta/a3_pyta.txt')
    checker_generic.run_pyta('poetry_reader.py', 'pyta/a3_pyta.txt')
    checker_generic.run_pyta('poetry_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')