File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,30 @@ def test_set_quiet(base_app):
184184 assert out == ['quiet: True' ]
185185
186186
187+ class OnChangeHookApp (cmd2 .Cmd ):
188+ def __init__ (self , * args , ** kwargs ):
189+ super ().__init__ (* args , ** kwargs )
190+
191+ def _onchange_quiet (self , old , new ) -> None :
192+ """Runs when quiet is changed via set command"""
193+ self .poutput ("You changed quiet" )
194+
195+ @pytest .fixture
196+ def onchange_app ():
197+ app = OnChangeHookApp ()
198+ app .stdout = utils .StdSim (app .stdout )
199+ return app
200+
201+ def test_set_onchange_hook (onchange_app ):
202+ out = run_cmd (onchange_app , 'set quiet True' )
203+ expected = normalize ("""
204+ quiet - was: False
205+ now: True
206+ You changed quiet
207+ """ )
208+ assert out == expected
209+
210+
187211def test_base_shell (base_app , monkeypatch ):
188212 m = mock .Mock ()
189213 monkeypatch .setattr ("{}.Popen" .format ('subprocess' ), m )
You can’t perform that action at this time.
0 commit comments