def test_describe(test_input, diff_return, expected, monkeypatch): monkeypatch.setattr(info, 'get_head', lambda x: 'repo') monkeypatch.setattr(info, 'run_quiet_diff', lambda _: diff_return) monkeypatch.setattr(info, 'get_commit_msg', lambda _: "msg") monkeypatch.setattr(info, 'has_untracked', lambda: True) monkeypatch.setattr('os.chdir', lambda x: None) print('expected: ', repr(expected)) print('got: ', repr(next(utils.describe(test_input)))) assert expected == next(utils.describe(test_input))
def test_describe(test_input, has_remote, expected, monkeypatch): monkeypatch.setattr(utils, 'get_head', lambda x: 'repo') monkeypatch.setattr(utils, 'has_remote', lambda: has_remote) monkeypatch.setattr(utils, 'get_commit_msg', lambda: "msg") monkeypatch.setattr('os.chdir', lambda x: None) # Returns of os.system determine the repo status monkeypatch.setattr('os.system', lambda x: True) print('expected: ', repr(expected)) print('got: ', repr(utils.describe(test_input))) assert expected == utils.describe(test_input)
def test_describe(test_input, diff_return, expected, monkeypatch): monkeypatch.setattr(info, "get_head", lambda x: "repo") monkeypatch.setattr(info, "run_quiet_diff", lambda *_: diff_return) monkeypatch.setattr(info, "get_commit_msg", lambda *_: "msg") monkeypatch.setattr(info, "get_commit_time", lambda *_: "xx") monkeypatch.setattr(info, "has_untracked", lambda *_: True) monkeypatch.setattr("os.chdir", lambda x: None) info.get_color_encoding.cache_clear() # avoid side effect assert expected == next(utils.describe(*test_input))