def test_force_overwriting_artifact_does_not_raise_error(self): host = FakeHost() output_dir = '%stmp' % host.sep ar = artifacts.Artifacts(output_dir, host, iteration=0, test_name='a.b.c', intial_results_base_dir=True) file_rel_path = host.join('stdout', 'test.txt') ar.CreateArtifact('artifact_name', file_rel_path, 'contents', write_as_text=True) self.assertEqual( host.read_text_file( host.join(output_dir, 'a.b.c', 'initial', 'stdout', 'test.txt')), 'contents') ar.CreateArtifact('artifact_name', file_rel_path, 'overwritten contents', force_overwrite=True, write_as_text=True) self.assertEqual( host.read_text_file( host.join(output_dir, 'a.b.c', 'initial', 'stdout', 'test.txt')), 'overwritten contents')
def test_file_manager_writes_file(self): host = FakeHost() output_dir = '%stmp' % host.sep ar = artifacts.Artifacts(output_dir, host, iteration=0) file_path = host.join('failures', 'stderr.txt') ar.CreateArtifact('artifact_name', file_path, 'exception raised', write_as_text=True) self.assertEqual(host.read_text_file(file_path), 'exception raised')