def test_GetGitConfigVal_invalid_key(monkeypatch): monkeypatch.setattr('subprocess.check_output', lambda *args, **kwargs: b'') assert utils.get_git_config_val('no_such_key') == ''
def test_GetGitConfigVal_command_error(monkeypatch): def raise_error(*args, **kwargs): raise CalledProcessError('255', 'cmd') monkeypatch.setattr('subprocess.check_output', raise_error) assert utils.get_git_config_val('github.user') is None
def test_command_error(self, check_output): check_output.side_effect = CalledProcessError('255', 'cmd') assert_equals(utils.get_git_config_val('github.user'), None)
def test_GetGitConfigVal_valid_key(monkeypatch): monkeypatch.setattr('subprocess.check_output', lambda *args, **kwargs: b'JNRowe') assert utils.get_git_config_val('github.user') == 'JNRowe'
def test_invalid_key(self, check_output): check_output.return_value = '' assert_equals(utils.get_git_config_val('no_such_key'), '')
def test_valid_key(self, check_output): check_output.return_value = 'JNRowe' assert_equals(utils.get_git_config_val('github.user'), 'JNRowe')
def test_valid_key(self, check_output): check_output.return_value = 'JNRowe' expect(utils.get_git_config_val('github.user')) == 'JNRowe'
def test_command_error(self, check_output): check_output.side_effect = CalledProcessError('255', 'cmd') expect(utils.get_git_config_val('github.user')) is None
def test_invalid_key(self, check_output): check_output.return_value = '' expect(utils.get_git_config_val('no_such_key')) == ''