def test_key_exception(self): error_caption = 'Key' patterns = [(None, 0, str(RequiredError(error_caption))), (1, 0, str(MyTypeError(error_caption, str, int))), ('Cm', 0, str(IncludeError(error_caption, 'Cm'))), (None, 1, str(RequiredError(error_caption))), (1, 1, str(MyTypeError(error_caption, str, int))), ('Cm', 1, str(IncludeError(error_caption, 'Cm')))] for target, tonal, expected in patterns: with self.subTest(target=target, tonal=tonal, expected=expected): actual = None try: self.target_class(target, tonal) except Exception as e: actual = str(e) self.assertEqual(expected, actual)
def test_beat_type_exception(self): patterns = [(None, str(RequiredError('BeatType'))), (-4, str(NaturalError('BeatType'))), ('4', str(MyTypeError('BeatType', int, str)))] for target, expected in patterns: with self.subTest(target=target, expected=expected): actual = None try: self.target_class(target) except Exception as e: actual = str(e) self.assertEqual(expected, actual)
def test_tonal_exception(self): error_caption = 'Tonal' patterns = [(None, str(RequiredError(error_caption))), (1, str(MyTypeError(error_caption, str, int))), ('Ionian', str(IncludeError(error_caption, 'Ionian')))] for target, expected in patterns: with self.subTest(target=target, expected=expected): actual = None try: self.target_class(target) except Exception as e: actual = str(e) self.assertEqual(expected, actual)
def test_octave_exception(self): error_caption = 'Octave' patterns = [(None, str(RequiredError(error_caption))), (-4, str(NaturalError(error_caption))), ('4', str(MyTypeError(error_caption, int, str)))] for target, expected in patterns: with self.subTest(target=target, expected=expected): actual = None try: self.target_class(target) except Exception as e: actual = str(e) self.assertEqual(expected, actual)
def test_chromatone_exception(self): error_caption = 'Chromatone' patterns = [ (None, str(RequiredError(error_caption))), ('1', str(MyTypeError(error_caption, float, str))), (6.0, str(IncludeError(error_caption, '6.0'))), ] for target, expected in patterns: with self.subTest(target=target, expected=expected): actual = None try: self.target_class(target) except Exception as e: actual = str(e) self.assertEqual(expected, actual)