File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,3 +7,4 @@ exclude_lines =
77 no-cov
88 def __repr__
99 raise NotImplementedError
10+ __name__ == " __main__" :
Original file line number Diff line number Diff line change 1+ import pytest
2+ import mock
3+
4+ from paths_cli .tests .wizard .mock_wizard import mock_wizard
5+
6+ from paths_cli .wizard .engines import engines , SUPPORTED_ENGINES
7+
8+ def test_engines ():
9+ wizard = mock_wizard (['foo' ])
10+ with mock .patch .dict (SUPPORTED_ENGINES ,
11+ {'foo' : mock .Mock (return_value = 'ran foo' )}):
12+ foo = engines (wizard )
13+ assert foo == 'ran foo'
14+
Original file line number Diff line number Diff line change 1+ import pytest
2+ import mock
3+
4+ from paths_cli .tests .wizard .mock_wizard import mock_wizard
5+
6+ from paths_cli .wizard .errors import *
7+
8+ def test_impossible_error_default ():
9+ with pytest .raises (ImpossibleError , match = "You should never see this." ):
10+ raise ImpossibleError ()
11+
12+ @pytest .mark .parametrize ('inputs' , ['r' , 'q' ])
13+ def test_not_installed (inputs ):
14+ expected = {'r' : RestartObjectException , 'q' : SystemExit }[inputs ]
15+ wizard = mock_wizard ([inputs ])
16+ with pytest .raises (expected ):
17+ not_installed (wizard , 'foo' , 'widget' )
18+ log = wizard .console .log_text
19+ assert 'foo installed' in log
20+ assert 'different widget' in log
21+
Original file line number Diff line number Diff line change @@ -7,16 +7,16 @@ def __init__(self, msg=None):
77class RestartObjectException (BaseException ):
88 pass
99
10- def not_installed (package , obj_type ):
11- retry = wizard .ask ("Hey, it looks like you don't have {package} "
10+ def not_installed (wizard , package , obj_type ):
11+ retry = wizard .ask (f "Hey, it looks like you don't have { package } "
1212 "installed. Do you want to try a different "
13- "{obj_type}, or do you want to quit?" ,
13+ f "{ obj_type } , or do you want to quit?" ,
1414 options = ["[R]etry" , "[Q]uit" ])
1515 if retry == 'r' :
16- return
16+ raise RestartObjectException ()
1717 elif retry == 'q' :
1818 exit ()
19- else :
19+ else : # no-cov
2020 raise ImpossibleError ()
2121
2222
You can’t perform that action at this time.
0 commit comments