def test_hash(self): this_class = Test_Absolute_Pitch self.assertEqual(hash(this_class.g_0), hash(this_class.g_0), 'identity') self.assertEqual(hash(this_class.c_0), hash(Absolute_Pitch(0, 'C', 0))) self.assertEqual(hash(this_class.b_sharp_4), hash(Absolute_Pitch(4, 'B', 1)))
def test_hash(self): this_class = Test_Absolute_Note self.assertEqual(hash(this_class.C4_whole), hash(this_class.C4_whole), 'identity') self.assertEqual(hash(this_class.B5_triplet), hash(Absolute_Note(Absolute_Pitch(5, 'B', 0), 1 / 3))) self.assertEqual(hash(this_class.B5_whole), hash(Absolute_Note(Absolute_Pitch(5, 'B', 0), 4)))
def test_eq(self): this_class = Test_Absolute_Note self.assertEqual(this_class.C4_whole, this_class.C4_whole, 'identity') self.assertEqual(this_class.B5_triplet, Absolute_Note(Absolute_Pitch(5, 'B', 0), 1 / 3), 'same note') self.assertFalse( this_class.B5_whole == Absolute_Note_Alt(Absolute_Pitch(5, 'B', 0), 4), 'different classes') self.assertNotEqual(this_class.B5_triplet, this_class.B5_whole, 'different durations') self.assertNotEqual(this_class.B5_whole, this_class.C4_whole, 'different pitches') self.assertNotEqual(this_class.C4_whole, this_class.B5_triplet, 'different pitches and durations')
def setUpClass(cls): cls.c_0 = Absolute_Pitch(0, 'C', 0) cls.g_0 = Absolute_Pitch(0, 'G', 0) cls.a_4 = Absolute_Pitch(4, 'A', 0) cls.b_doubleflat_4 = Absolute_Pitch(4, 'B', -2) cls.b_sharp_4 = Absolute_Pitch(4, 'B', 1) cls.a_5 = Absolute_Pitch(5, 'A', 0)
def test_eq(self): this_class = Test_Absolute_Pitch self.assertEqual(this_class.c_0, this_class.c_0, 'identity') self.assertEqual(this_class.a_4, Absolute_Pitch(4, 'A', 0), 'same pitch') self.assertFalse(this_class.a_4 == Absolute_Pitch_Alt(4, 'A', 0), 'different classes') self.assertNotEqual(this_class.a_4, this_class.b_doubleflat_4, 'enharmonics') self.assertNotEqual(this_class.a_4, this_class.a_5, 'different octaves') self.assertNotEqual(this_class.c_0, this_class.g_0, 'different note names') self.assertNotEqual(this_class.b_doubleflat_4, this_class.b_sharp_4, 'different accidentals')
def setUpClass(cls): cls.C4_whole = Absolute_Note(Absolute_Pitch(4, 'C', 0), 4) cls.B5_triplet = Absolute_Note(Absolute_Pitch(5, 'B', 0), 1 / 3) cls.B5_whole = Absolute_Note(Absolute_Pitch(5, 'B', 0), 4)
def test_to_absolute_C_high(self): # no sharps or flats; pitch is in octave > 0 and in key e_5 = Absolute_Pitch(5, 'E', 0) self.assertEqual(Test_Relative_Pitch.high_mediant.to_absolute('C'), e_5)
def test_to_absolute_E_accidentals(self): # key signature has sharps; pitch is in octave 0 and has sharps a_sharp_4 = Absolute_Pitch(4, 'A', 1) self.assertEqual( Test_Relative_Pitch.middle_subdominant_sharp.to_absolute('E'), a_sharp_4)
def test_to_absolute_C_flat(self): # key name has accidental; key signature has flats; pitch has negative octave and no accidentals b_flat_2 = Absolute_Pitch(2, 'B', -1) self.assertEqual( Test_Relative_Pitch.low_leading_tone.to_absolute('C-'), b_flat_2)