def testOutputParser(self): output = (b'[ 0.0] Opening the source -i libvirt ://roo...\n' b'[ 1.0] Creating an overlay to protect the f...\n' b'[ 88.0] Copying disk 1/2 to /tmp/v2v/0000000...\n' b' (0/100%)\r' b'some messages\r' b' (25/100%)\r' b'more messages\n' b' (50/100%)\r' b'much much more messages\r\n' b' (100/100%)\r' b'[ 180.0] Copying disk 2/2 to /tmp/v2v/100000-...\n' b' (0/100%)\r' b' (50/100%)\r' b' (100/100%)\r' b'[ 256.0] Creating output metadata' b'[ 256.0] Finishing off') parser = v2v.OutputParser() events = list(parser.parse(io.BytesIO(output))) assert events == [(v2v.ImportProgress(1, 2, b'Copying disk 1/2')), (v2v.DiskProgress(0)), (v2v.DiskProgress(25)), (v2v.DiskProgress(50)), (v2v.DiskProgress(100)), (v2v.ImportProgress(2, 2, b'Copying disk 2/2')), (v2v.DiskProgress(0)), (v2v.DiskProgress(50)), (v2v.DiskProgress(100))]
def testOutputParser(self): output = (u'[ 0.0] Opening the source -i libvirt ://roo...\n' u'[ 1.0] Creating an overlay to protect the f...\n' u'[ 88.0] Copying disk 1/2 to /tmp/v2v/0000000...\n' u' (0/100%)\r' u' (50/100%)\r' u' (100/100%)\r' u'[ 180.0] Copying disk 2/2 to /tmp/v2v/100000-...\n' u' (0/100%)\r' u' (50/100%)\r' u' (100/100%)\r' u'[ 256.0] Creating output metadata' u'[ 256.0] Finishing off') parser = v2v.OutputParser() events = list(parser.parse(StringIO(output))) self.assertEqual(events, [ (v2v.ImportProgress(1, 2, 'Copying disk 1/2')), (v2v.DiskProgress(0)), (v2v.DiskProgress(50)), (v2v.DiskProgress(100)), (v2v.ImportProgress(2, 2, 'Copying disk 2/2')), (v2v.DiskProgress(0)), (v2v.DiskProgress(50)), (v2v.DiskProgress(100))])