summaryrefslogtreecommitdiff
path: root/tests/test_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_plugin.py')
-rw-r--r--tests/test_plugin.py24
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
#
###