Пример #1
0
 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)))
Пример #2
0
 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(self):
     for degree in list(Degree.Degrees) + [(dd[0] + 7, dd[1] + 12)
                                           for dd in Degree.Degrees]:
         for accidental in Accidental.Accidentals.keys():
             with self.subTest(degree=degree, accidental=accidental):
                 if None is accidental: continue
                 degreeName = accidental + str(degree[0])
                 expected = degree[1] + Accidental.Accidentals[accidental]
                 self.assertEqual(expected, Degree.Get(degreeName))
 def Get(cls, name: str):
     if not (isinstance(name, str)):
         raise TypeError(f'引数nameはstr型にしてください。: type(name)={type(name)}')
     prefix, degree = cls.__Split(name)
     if degree < 1 or 14 < degree:
         raise ValueError(f'degreeは1〜14までの自然数にしてください。: degree={degree}')
     cls.__ValidPrefixDegree(prefix, degree)
     return Degree.Get(degree) + cls.__GetRelativeHalfToneNum(
         prefix, degree)
 def test_Get(self):
     for degree in list(Degree.Degrees) + [(dd[0]+7,dd[1]+12) for dd in Degree.Degrees]:
         for acc_count in range(1, 4):
             for accidental in Accidental.Accidentals.keys():
                 if None is accidental: continue
                 with self.subTest(degree=degree, accidental=accidental*acc_count):
                     degreeName = (accidental * acc_count) + str(degree[0])
                     expected = degree[1] + (Accidental.Accidentals[accidental] * acc_count)
                     self.assertEqual(expected, Degree.Get(degreeName))
Пример #6
0
 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)))
Пример #7
0
 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_OutOfRangeNumber_15(self):
     with self.assertRaises(ValueError) as e:
         Degree.Get('15')
     self.assertIn('degreeは1〜14までの自然数のみ有効です。', str(e.exception))
 def test_Get_OutOfRangeNumber_0(self):
     with self.assertRaises(ValueError) as e:
         Degree.Get('0')
     self.assertIn('引数nameに有効な数字が含まれていません。1〜14までの自然数を含めてください。',
                   str(e.exception))
 def test_Get_int(self):
     with self.assertRaises(TypeError) as e:
         Degree.Get(100)
     self.assertIn('引数nameはstr型にしてください。', str(e.exception))
 def test_Get_8_14(self):
     for d in [(dd[0] + 7, dd[1] + 12) for dd in Degree.Degrees]:
         self.assertEqual(d[1], Degree.Get(str(d[0])))
 def test_Get_1_7(self):
     for d in Degree.Degrees:
         self.assertEqual(d[1], Degree.Get(str(d[0])))
 def test_Get_int_15(self):
     with self.assertRaises(ValueError) as e:
         Degree.Get(15)
     self.assertIn('degreeは1〜14までの自然数のみ有効です。', str(e.exception))
 def test_Get_int(self):
     for degree in range(1, 15):
         i, o = (degree - 1, 0) if degree < 8 else ((degree - 1) - 7, 1)
         expected = Degree.Degrees[i][1] + o * 12
         self.assertEqual(expected, Degree.Get(degree))
 def test_Get_Blank(self):
     with self.assertRaises(ValueError) as e:
         Degree.Get('')
     self.assertIn('引数nameに有効な数字が含まれていません。1〜14までの自然数を含めてください。',
                   str(e.exception))