Debian Codegraph @

tests/test_future_annotations.py

raw symbols SCIP
1 from __future__ import annotations
2
3 import cmd2
4
5 from .conftest import normalize, run_cmd
6
7
8 def test_hooks_work_with_future_annotations() -> None:
9 class HookApp(cmd2.Cmd):
10 def __init__(self, *args, **kwargs) -> None:
11 super().__init__(*args, **kwargs)
12 self.register_cmdfinalization_hook(self.hook)
13
14 def hook(self: cmd2.Cmd, data: cmd2.plugin.CommandFinalizationData) -> cmd2.plugin.CommandFinalizationData:
15 if self.in_script():
16 self.poutput("WE ARE IN SCRIPT")
17 return data
18
19 hook_app = HookApp()
20 out, _err = run_cmd(hook_app, "")
21 expected = normalize("")
22 assert out == expected