diff options
| author | Eric Lin <anselor@gmail.com> | 2020-07-07 15:57:02 -0400 |
|---|---|---|
| committer | anselor <anselor@gmail.com> | 2020-07-11 17:30:40 -0400 |
| commit | 601a8e271020ca1b0918deabf70ad0778ded7d4a (patch) | |
| tree | 48f2134a71a2478c00eb9df33e69b30c0ae39002 /plugins/ext_test/examples | |
| parent | 28e43bf24f8a5bc0b2e896938e76e17524d12ed3 (diff) | |
| download | cmd2-git-601a8e271020ca1b0918deabf70ad0778ded7d4a.tar.gz | |
external test plugin tests and coverage should now run
Diffstat (limited to 'plugins/ext_test/examples')
| -rw-r--r-- | plugins/ext_test/examples/example.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/plugins/ext_test/examples/example.py b/plugins/ext_test/examples/example.py new file mode 100644 index 00000000..649f8627 --- /dev/null +++ b/plugins/ext_test/examples/example.py @@ -0,0 +1,38 @@ +# +# coding=utf-8 +# import cmd2 +import cmd2 +import cmd2_ext_test +import cmd2.py_bridge + + +class Example(cmd2.Cmd): + """An class to show how to use a plugin""" + def __init__(self, *args, **kwargs): + # gotta have this or neither the plugin or cmd2 will initialize + super().__init__(*args, **kwargs) + + def do_something(self, arg): + self.last_result = 5 + self.poutput('this is the something command') + + +class ExampleTester(cmd2_ext_test.ExternalTestMixin, Example): + def __init__(self, *args, **kwargs): + # gotta have this or neither the plugin or cmd2 will initialize + super().__init__(*args, **kwargs) + + +if __name__ == '__main__': + app = ExampleTester() + + try: + app.fixture_setup() + + out = app.app_cmd("something") + assert isinstance(out, cmd2.CommandResult) + + assert out.data == 5 + + finally: + app.fixture_teardown() |
