def test_search_for_no_match(self): content = dedent(""" HelloWorld Goodbye World """) with open_mock(content): with Capture(silent=True): self.assertRaises(SystemExit, search_for, "foo", r"(NoMatch)")
def test_tag_with_custom_message_bad_placeholder(self): os.chdir(self.repo_dir) with open(os.path.join(self.repo_dir, '.tito', 'tito.props'), 'a') as f: f.write('tag_commit_message_format = %(ultimate_answer)s\n') with Capture(silent=True) as capture: self.assertRaises(SystemExit, tito, "tag --accept-auto-changelog") self.assertIn("Unknown placeholder 'ultimate_answer' in tag_commit_message_format", capture.err)
def test_renders_cheetah_missing_result(self, mock_tempfile, mock_run_command, mock_glob, mock_unlink): mock_run_command.return_value = True mock_tempfile.return_value.name = "temp_pickle" mock_unlink.return_value = True mock_glob.return_value = [] with Capture(silent=True): self.assertRaises(SystemExit, render_cheetah, "foo.spec.tmpl", "/tmp", {}) expected = "cheetah fill --flat --pickle=temp_pickle --odir=/tmp --oext=cheetah foo.spec.tmpl" self.assertEquals(call(expected), mock_run_command.mock_calls[0]) self.assertEquals(call("/tmp/*.cheetah"), mock_glob.mock_calls[0]) self.assertEquals(call("temp_pickle"), mock_unlink.mock_calls[0])
def test_find_file_with_extension_duplicates(self, mock_listdir): mock_listdir.return_value = ["hello.txt", "goodbye.txt"] with Capture(silent=True): self.assertRaises(SystemExit, find_file_with_extension, "/tmp", ".txt")
def test_find_spec_like_file_no_match(self, mock_find): mock_find.side_effect = [None, None] with Capture(silent=True): self.assertRaises(SystemExit, find_spec_like_file) self.assertEquals(2, len(mock_find.mock_calls))
def test_tag_rejected(self): with Capture(silent=True): self.assertRaises( SystemExit, tito, 'build --tag=extsrc-0.0.1-1 --rpm --output=%s --arg=source=%s ' % (self.output_dir, self.source_filename))