diff options
author | kotfu <kotfu@kotfu.net> | 2018-07-15 15:50:13 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-07-15 15:50:13 -0600 |
commit | 8e930af452c4a7f50aa4fafb1bab4201337a4ded (patch) | |
tree | 6e10dc9bad65598e876ccb39ce437ff5b24c3181 /tests/test_plugin.py | |
parent | 10ee6ba4291695ade3a8fe4f5b78582c67dada8d (diff) | |
download | cmd2-git-8e930af452c4a7f50aa4fafb1bab4201337a4ded.tar.gz |
Fix for #417, call preparse()
Diffstat (limited to 'tests/test_plugin.py')
-rw-r--r-- | tests/test_plugin.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_plugin.py b/tests/test_plugin.py index fd8609c3..e401e837 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -22,6 +22,7 @@ class Plugin: self.reset_counters() def reset_counters(self): + self.called_preparse = 0 self.called_postparsing = 0 self.called_precmd = 0 self.called_postcmd = 0 @@ -51,6 +52,16 @@ class Plugin: ### # + # preparse hook + # + ### + def preparse(self, line: str) -> str: + "Preparsing hook" + self.called_preparse += 1 + return line + + ### + # # Postparsing hooks # ### @@ -310,6 +321,19 @@ def test_postloop_hooks(capsys): ### # +# test preparse hook +# +### +def test_preparse(capsys): + app = PluggedApp() + app.onecmd_plus_hooks('say hello') + out, err = capsys.readouterr() + assert out == 'hello\n' + assert not err + assert app.called_preparse == 1 + +### +# # test postparsing hooks # ### |