def setUp(self): terminal_width = 20 self._terminal = self.PatchObject(operation.ProgressBarOperation, '_GetTerminalSize', return_value=operation._TerminalSize( 100, terminal_width)) self.PatchObject(os, 'isatty', return_value=True)
def _VerifyProgressBar(self, width, percent, expected_shaded, expected_unshaded): """Helper to test progress bar with different percentages and lengths.""" terminal_width = width + ( operation.ProgressBarOperation._PROGRESS_BAR_BORDER_SIZE) self._terminal.return_value = operation._TerminalSize(100, terminal_width) op = operation.ProgressBarOperation() with self.OutputCapturer() as output: op.ProgressBar(percent) stdout = output.GetStdout() #Check that the shaded and unshaded regions are the expected size. self.assertEqual(stdout.count('#'), expected_shaded) self.assertEqual(stdout.count('-'), expected_unshaded)
def _VerifyProgressBar(self, width, percent, expected_shaded, expected_unshaded): """Helper to test progress bar with different percentages and lengths.""" terminal_width = width + ( operation.ProgressBarOperation._PROGRESS_BAR_BORDER_SIZE) self._terminal.return_value = operation._TerminalSize( 100, terminal_width) op = operation.ProgressBarOperation() with self.OutputCapturer() as output: op.ProgressBar(percent) stdout = output.GetStdout() # Check that the shaded and unshaded regions are the expected size. self.assertEqual(stdout.count('#'), expected_shaded) self.assertEqual(stdout.count('-'), expected_unshaded)
def setUp(self): terminal_width = 20 self._terminal = self.PatchObject( operation.ProgressBarOperation, '_GetTerminalSize', return_value=operation._TerminalSize(100, terminal_width)) self.PatchObject(os, 'isatty', return_value=True)