Make test more readable

This commit is contained in:
Raymond Sun 2021-06-14 16:02:28 +10:00
parent 6a9cc9e5ea
commit 9ff1697939

View File

@ -253,13 +253,16 @@ def test_extensions(tempdir):
assert ns['extensions'] == ['foo', 'bar', 'baz'] assert ns['extensions'] == ['foo', 'bar', 'baz']
def test_exits_upon_existing_confpy(monkeypatch): def test_exits_when_existing_confpy(monkeypatch):
# The code detects existing conf.py with isfile() so we mock it # The code detects existing conf.py with path.isfile()
# so we mock it as True with pytest's monkeypatch
def mock_isfile(path): def mock_isfile(path):
return True return True
monkeypatch.setattr(path, 'isfile', mock_isfile) monkeypatch.setattr(path, 'isfile', mock_isfile)
qs.term_input = mock_input({}) qs.term_input = mock_input({
'Please enter a new root path (or just Enter to exit)': ''
})
d = {} d = {}
with pytest.raises(SystemExit): with pytest.raises(SystemExit):
qs.ask_user(d) qs.ask_user(d)