From 864a0b377d3ef6526837dfb721c260587ccb64f9 Mon Sep 17 00:00:00 2001 From: Raymond Sun Date: Fri, 11 Jun 2021 23:06:03 +1000 Subject: [PATCH] Add test --- tests/test_quickstart.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/test_quickstart.py b/tests/test_quickstart.py index 94144ef22..96b11daec 100644 --- a/tests/test_quickstart.py +++ b/tests/test_quickstart.py @@ -10,6 +10,7 @@ import time from io import StringIO +from os import path import pytest @@ -122,7 +123,6 @@ def test_quickstart_defaults(tempdir): assert (tempdir / 'Makefile').isfile() assert (tempdir / 'make.bat').isfile() - def test_quickstart_all_answers(tempdir): answers = { 'Root path': tempdir, @@ -250,3 +250,17 @@ def test_extensions(tempdir): ns = {} exec(conffile.read_text(), ns) assert ns['extensions'] == ['foo', 'bar', 'baz'] + +def test_easy_exit_when_existing_confpy(monkeypatch): + # The code detects existing conf.py with isfile() so we mock it + def mock_isfile(path): + return True + monkeypatch.setattr(path, 'isfile', mock_isfile) + + answers = { + 'Please enter a new root path': '', + } + qs.term_input = mock_input(answers) + d = {} + with pytest.raises(SystemExit): + qs.ask_user(d) \ No newline at end of file