Skip to content

Commit 97189a6

Browse files
committed
split off _do_one in wizard
1 parent 35c9ca1 commit 97189a6

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

‎paths_cli/tests/wizard/test_wizard.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def test_storage_description_line(self, count):
197197
assert line == expected
198198

199199
def test_save_to_file(self):
200-
pass
200+
pytest.skip()
201201

202202
@pytest.mark.parametrize('req,count,expected', [
203203
(('cvs', 1, 1), 0, (True, True)),
@@ -222,5 +222,8 @@ def test_ask_do_another(self, inputs, expected):
222222
if len(inputs) > 1:
223223
assert "Sorry" in console.log_text
224224

225+
def test_do_one(self):
226+
pytest.skip()
227+
225228
def test_run_wizard(self):
226-
pass
229+
pytest.skip()

‎paths_cli/wizard/wizard.py‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,22 @@ def _ask_do_another(self, obj_type):
242242
self.bad_input("Sorry, I didn't understand that.")
243243
return do_another
244244

245+
def _do_one(self, step, req):
246+
try:
247+
obj = step.func(self)
248+
except RestartObjectException:
249+
self.say("Okay, let's try that again.")
250+
return True
251+
self.register(obj, step.display_name, step.store_name)
252+
requires_another, allows_another = self._req_do_another(req)
253+
if requires_another:
254+
do_another = True
255+
elif not requires_another and allows_another:
256+
do_another = self._ask_do_another(step.display_name)
257+
else:
258+
do_another = False
259+
return do_another
260+
245261
def run_wizard(self):
246262
self.start("Hi! I'm the OpenPathSampling Wizard.")
247263
# TODO: next line is only temporary
@@ -251,20 +267,7 @@ def run_wizard(self):
251267
req = step.store_name, step.minimum, step.maximum
252268
do_another = True
253269
while do_another:
254-
try:
255-
obj = step.func(self)
256-
except RestartObjectException:
257-
self.say("Okay, let's try that again.")
258-
continue
259-
self.register(obj, step.display_name, step.store_name)
260-
requires_another, allows_another = self._req_do_another(req)
261-
if requires_another:
262-
do_another = True
263-
elif not requires_another and allows_another:
264-
do_another = self._ask_do_another(step.display_name)
265-
else:
266-
do_another = False
267-
270+
do_another = self._do_one(step, req)
268271
storage = self.get_storage()
269272
self.save_to_file(storage)
270273

0 commit comments

Comments
 (0)