示例#1
0
 def testReadBadCount(self):
     handle = StringIO("""BEAT_START
     COUNT |^e+d|
     BEAT_END""")
     iterator = fileUtils.dbFileIterator(handle)
     self.assertRaises(DBErrors.BadCount, dbfsv1.BeatStructureV1().read,
                       iterator)
示例#2
0
 def testReadBadTicks(self):
     handle = StringIO("""BEAT_START
     NUM_TICKS x
     COUNT |^e+a|
     BEAT_END""")
     iterator = fileUtils.dbFileIterator(handle)
     self.assertRaises(DBErrors.InvalidInteger, dbfsv1.BeatStructureV1().read,
                       iterator)
示例#3
0
 def testReadPartial(self):
     handle = StringIO("""BEAT_START
     NUM_TICKS 2
     COUNT |^e+a|
     BEAT_END""")
     iterator = fileUtils.dbFileIterator(handle)
     beat = dbfsv1.BeatStructureV1().read(iterator)
     self.assertEqual("".join(beat.count(1)), "1e")
示例#4
0
 def testReadBadLine(self):
     handle = StringIO("""BEAT_START
     NUM_TICKS 4
     COUNT |^e+a|
     BAD_LINE xxx
     BEAT_END""")
     iterator = fileUtils.dbFileIterator(handle)
     self.assertRaises(DBErrors.UnrecognisedLine,
                       dbfsv1.BeatStructureV1().read, iterator)
示例#5
0
 def testWritePartialBeat(self):
     beat = Beat.Beat(Counter.Counter("e+a"), 2)
     handle = StringIO()
     indenter = fileUtils.Indenter(handle)
     dbfsv1.BeatStructureV1().write(beat, indenter)
     output = handle.getvalue().splitlines()
     self.assertEqual(output,
                      ["BEAT_START",
                       "  NUM_TICKS 2",
                       "  COUNT |^e+a|",
                       "BEAT_END"])