def test_get_output_stream_opens_correct_file(self): format = 'xml' output = tempfile.mktemp() self.addCleanup(os.unlink, output) output_stream = run.get_output_stream(format, output) self.assertThat(output_stream.name, Equals(output))
def make_result_object(self): output_path = tempfile.mktemp() self.addCleanup(remove_if_exists, output_path) result_constructor = testresult.get_output_formats()[self.format] return result_constructor( stream=run.get_output_stream(self.format, output_path), failfast=False, )
def get_supported_options(self, **kwargs): """Get a dictionary of all supported keyword arguments for the current result class. Pass in keyword arguments to override default options. """ output_path = tempfile.mktemp() self.addCleanup(remove_if_exists, output_path) options = { 'stream': run.get_output_stream(self.format, output_path), 'failfast': False } options.update(kwargs) return options
def test_subunit_format_opens_raw_binary_mode_stream(self): output = tempfile.mktemp() format = 'subunit' with patch.object(run, '_get_raw_binary_mode_file_stream') as pgrbs: run.get_output_stream(format, output) pgrbs.assert_called_once_with(output)
def test_xml_format_opens_text_mode_stream(self): output = tempfile.mktemp() format = 'xml' with patch.object(run, '_get_text_mode_file_stream') as pgts: run.get_output_stream(format, output) pgts.assert_called_once_with(output)
def test_get_output_stream_gets_stdout_with_no_logfile_specified(self): output_stream = run.get_output_stream('text', None) self.assertThat(output_stream.name, Equals('<stdout>'))