Esempio n. 1
0
 def testUpdateMessageInvalidMessage(self):
   stream = io.StringIO()
   mco = multiline.MultilineConsoleOutput(stream)
   stray_message = multiline.MultilineConsoleMessage('asdf', stream)
   with self.assertRaisesRegex(
       ValueError,
       'The given message does not belong to this output object.'):
     mco.UpdateMessage(stray_message, 'fdsa')
Esempio n. 2
0
 def testPrintAddsNewlineToLastLine(self, indentation_level):
     console_size = self.SetConsoleSize(15 + 2 * indentation_level)
     indentation = ' ' * 2 * indentation_level
     stream = io.StringIO()
     scm = multiline.MultilineConsoleMessage(
         'My message', stream, indentation_level=indentation_level)
     scm.Print()
     scm.Print()
     self.assertEqual(
         # Print 1
         '\r' + ' ' * console_size + '\r' + indentation + 'My message\n' +
         # Print 2
         '\r' + ' ' * console_size + '\r' + indentation + 'My message\n',
         stream.getvalue())
Esempio n. 3
0
 def testHasUpdate(self, indentation_level):
     console_size = self.SetConsoleSize(15 + 2 * indentation_level)
     indentation = ' ' * 2 * indentation_level
     stream = io.StringIO()
     scm = multiline.MultilineConsoleMessage(
         'My message', stream, indentation_level=indentation_level)
     self.assertTrue(scm.has_update)
     scm.Print()
     self.assertFalse(scm.has_update)
     scm._UpdateMessage('egassem yM')
     self.assertTrue(scm.has_update)
     scm.Print()
     self.assertFalse(scm.has_update)
     self.assertEqual(
         # Print 1
         '\r' + ' ' * console_size + '\r' + indentation + 'My message\n' +
         # Print 2
         '\r' + ' ' * console_size + '\r' + indentation + 'egassem yM\n',
         stream.getvalue())