def test_create_zip_exception(self): workspace = Workspace( None, MockExecutive(should_log=True, should_throw=True)) expected_logs = """MOCK run_command: ['zip', '-9', '-r', '/zip/path', '.'], cwd=/source/path Workspace.create_zip failed in /source/path: MOCK ScriptError output: MOCK output of child process """ class MockZipFile(object): def __init__(self, path): self.filename = path archive = OutputCapture().assert_outputs( self, workspace.create_zip, ["/zip/path", "/source/path", MockZipFile], expected_logs=expected_logs) self.assertIsNone(archive)
def test_create_zip_exception(self): workspace = Workspace( None, MockExecutive(should_log=True, should_throw=True)) class MockZipFile(object): def __init__(self, path): self.filename = path with OutputCapture(level=logging.INFO) as captured: archive = workspace.create_zip('/zip/path', '/source/path', MockZipFile) self.assertEqual( captured.root.log.getvalue(), '''MOCK run_command: ['zip', '-9', '-r', '/zip/path', '.'], cwd=/source/path Workspace.create_zip failed in /source/path: MOCK ScriptError MOCK output of child process ''', ) self.assertIsNone(archive)