def test_Get_Diminished(self): for degree in Interval.Perfects: with self.subTest(prefix='d', degree=degree): self.assertEqual( Degree.Get(str(degree)) - 1, Interval.Get('d' + str(degree))) for degree in Interval.Majors: with self.subTest(prefix='d', degree=degree): self.assertEqual( Degree.Get(str(degree)) - 2, Interval.Get('d' + str(degree)))
def test_Get_Augumented(self): degrees = list(Interval.Perfects) + list(Interval.Majors) degrees.sort() for degree in degrees: with self.subTest(prefix='a', degree=degree): self.assertEqual( Degree.Get(str(degree)) + 1, Interval.Get('a' + str(degree)))
def test_Get_Bad_Combination(self): with self.assertRaises(ValueError) as e: Interval.Get('P2') self.assertIn( 'prefixとdegreeの組合せが不正です。P(1|4|5|8|11|12), M|m(2|3|6|7|9|10|13|14), a|d(1〜14) のいずれかにしてください。', str(e.exception)) for degree in Interval.Perfects: for prefix in ['M', 'm']: with self.subTest(prefix=prefix, degree=degree): with self.assertRaises(ValueError) as e: Interval.Get(prefix + str(degree)) self.assertIn( 'prefixとdegreeの組合せが不正です。P(1|4|5|8|11|12), M|m(2|3|6|7|9|10|13|14), a|d(1〜14) のいずれかにしてください。', str(e.exception)) for degree in Interval.Majors: with self.subTest(prefix=prefix, degree=degree): with self.assertRaises(ValueError) as e: Interval.Get('P' + str(degree)) self.assertIn( 'prefixとdegreeの組合せが不正です。P(1|4|5|8|11|12), M|m(2|3|6|7|9|10|13|14), a|d(1〜14) のいずれかにしてください。', str(e.exception))
def test_Get_Invalid(self): with self.assertRaises(ValueError) as e: Interval.Get('無効値') self.assertIn('引数nameが有効な書式ではありません。', str(e.exception))
def test_Get_OutOfRange_15(self): with self.assertRaises(ValueError) as e: Interval.Get('P15') self.assertIn('degreeは1〜14までの自然数にしてください。', str(e.exception))
def test_Get_int(self): with self.assertRaises(TypeError) as e: Interval.Get(100) self.assertIn('引数nameはstr型にしてください。', str(e.exception))
def test_Get_Minors(self): for degree in Interval.Majors: with self.subTest(prefix='m', degree=degree): self.assertEqual( Degree.Get(str(degree)) - 1, Interval.Get('m' + str(degree)))
def test_Get_Perfects(self): for degree in Interval.Perfects: with self.subTest(prefix='P', degree=degree): self.assertEqual(Degree.Get(degree), Interval.Get('P' + str(degree)))
def test_Get_OutOfRange_0(self): with self.assertRaises(ValueError) as e: Interval.Get('P0') self.assertIn( '引数nameが有効な書式ではありません。(?P<prefix>[P|M|m|a|d])(?P<degree>[1-9][0-9]?)の書式にしてください。', str(e.exception))