Ejemplo n.º 1
0
 def test_print_warning(self):
     result_queue = queue.Queue()
     print_task = PrintTask(message="Bad File.", warning=True)
     thread = PrintThread(result_queue, False)
     with mock.patch('sys.stdout', new=six.StringIO()) as mock_stdout:
         thread._process_print_task(print_task)
         self.assertIn("Bad File.", mock_stdout.getvalue())
Ejemplo n.º 2
0
    def test_print_warning_quiet(self):
        print_task = PrintTask(message="Bad File.", warning=True)

        # Ensure a warned task is not printed to stderr when
        # ``quiet`` is True.
        thread = PrintThread(result_queue=self.result_queue,
                             quiet=True, only_show_errors=False)
        self.assert_expected_output(print_task, '', thread, 'sys.stderr')
Ejemplo n.º 3
0
    def test_print_only_show_errors(self):
        print_task = PrintTask(message="Success", error=False)

        # Ensure a succesful task is not printed to stdout when
        # ``only_show_errors`` is True.
        thread = PrintThread(result_queue=self.result_queue,
                             quiet=False, only_show_errors=True)
        self.assert_expected_output(print_task, '', thread, 'sys.stdout')
Ejemplo n.º 4
0
    def test_print_error_only_show_errors(self):
        print_task = PrintTask(message="Fail File.", error=True)

        # Ensure a failed task is printed to stderr when
        # ``only_show_errors`` is True.
        thread = PrintThread(result_queue=self.result_queue,
                             quiet=False, only_show_errors=True)
        self.assert_expected_output(print_task, 'Fail File.', thread,
                                    'sys.stderr')
Ejemplo n.º 5
0
 def test_print_decoding_error_message(self):
     # This ensures that if the message being passed to the print string
     # is from a decoding error. It can be outputted properly.
     decoding_error = FileDecodingError('temp', b'\xe2\x9c\x93')
     print_task = PrintTask(message=decoding_error.error_message,
                            warning=True)
     thread = PrintThread(result_queue=self.result_queue,
                          quiet=False,
                          only_show_errors=False)
     self.assert_expected_output(print_task, decoding_error.error_message,
                                 thread, 'sys.stderr')