def test_last_commit_not_in_repo(self): with mock.patch('subprocess.check_output', side_effect=subprocess.CalledProcessError(255, '', '')): self.assertEqual(None, hg.last_commit())
def test_last_commit(self): with mock.patch('subprocess.check_output', return_value=b'0a' * 20 + b'\n') as hg_call: self.assertEqual('0a' * 20, hg.last_commit()) hg_call.asser_called_once_with( ['hg', 'parent', '--template={node}'])
def test_last_commit_not_in_repo(self, check_output): check_output.side_effect = subprocess.CalledProcessError(255, '', '') self.assertEqual(None, hg.last_commit())
def test_last_commit(self, check_output): self.assertEqual('0a' * 20, hg.last_commit()) check_output.assert_called_once_with( ['hg', 'parent', '--template={node}'], stderr=subprocess.STDOUT)