Esempio n. 1
0
 def test_init_errors(self):
     pass
     with self.assertRaises(ValueError):
         notes = (Note(1), Note(2), Note(3))
         for _ in range(NoteList.max_depth + 1):
             notes = [notes]
         NoteList(notes)
     with self.assertRaises(
             TypeError):  # Expected iterable of Notes or NoteList
         NoteList(object())
Esempio n. 2
0
 def test_equality(self):
     c1 = Chord(Note(69), Note(73), Note(76))
     c2 = Chord(Note(69), Note(73), Note(76))
     self.assertEqual(c1, c2)
     nl_ordered = NoteList(Note(69), Note(73), Note(76))  # Pre-ordered
     self.assertEqual(nl_ordered, c1)
     nl_unordered = NoteList(Note(73), Note(69), Note(76))  # Un-ordered
     self.assertEqual(nl_unordered, c1)
     seq1 = Sequence(Note(69), Note(73), Note(76))
     self.assertNotEqual(c1, seq1)
     # Different note list lengths should automatically be not equal
     c3 = Chord(Note(69), Note(73), Note(76), Note(100))
     self.assertNotEqual(c1, c3)
Esempio n. 3
0
 def test_eq_notelist(self):
     notes = (Note(15), Note(10), Note(20))
     seq1 = Sequence(notes)
     nl1 = NoteList(notes)
     self.assertEqual(seq1, nl1)
Esempio n. 4
0
 def test_init_from_iter(self):
     nl1 = NoteList(Note(5), Note(7))
     self.assertEqual(nl1._notes, (Note(5), Note(7)))
     nl2 = NoteList([Note(5), Note(7)])
     self.assertEqual(nl2._notes, (Note(5), Note(7)))
Esempio n. 5
0
 def test_hash(self):
     notes = (Note(10), Note(15), Note(20)
              )  # Sorted to emulate NoteList.notes setter method
     nl1 = NoteList(notes)
     self.assertEqual(hash(notes), hash(nl1))
Esempio n. 6
0
 def test_from_midi_list(self):
     nl1 = NoteList.from_midi_list([69, 73, 76])
     self.assertEqual(nl1.notes, (Note(69), Note(73), Note(76)))
Esempio n. 7
0
 def test_from_ascii(self):
     expected = (Note(69), Note(73), Note(76))
     nl1 = NoteList.from_ascii("A4, C#5, E5")
     nl2 = NoteList.from_ascii("A4 C#5 E5")
     self.assertEqual(nl1.notes, expected)
     self.assertEqual(nl2.notes, expected)
Esempio n. 8
0
 def test_init_from_int(self):
     nl1 = NoteList(1, 2, 3)
     nl2 = NoteList(Note(1), Note(2), Note(3))
     self.assertEqual(nl1, nl2)
Esempio n. 9
0
 def test_init_from_NoteList(self):
     nl1 = NoteList(Note(5), Note(7))
     self.assertEqual(NoteList(nl1), nl1)