diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-16 20:09:04 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-03-16 20:09:04 -0400 |
commit | d590116b0a9efdb874713a0755cc362bd898112a (patch) | |
tree | bca90446f696fca6734ed991b96018c0c129c586 /examples | |
parent | 7dfd95cdeae12d8b8d788769df98945fd3f2f422 (diff) | |
download | cmd2-git-d590116b0a9efdb874713a0755cc362bd898112a.tar.gz |
Fix unit tests and example
functools.partialmethod() was added in Python 3.4, so it can't be used in Python 2.7.
- Modified the code to skip trying to use it for Python 2.7
- Skip the two unit tests which test its usage on Python 2.7
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/subcommands.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/subcommands.py b/examples/subcommands.py index bc276dff..fa99f6b4 100755 --- a/examples/subcommands.py +++ b/examples/subcommands.py @@ -8,6 +8,7 @@ and provides separate contextual help. """ import argparse import functools +import sys import cmd2 from cmd2 import with_argparser, index_based_complete @@ -69,8 +70,10 @@ class SubcommandsExample(cmd2.Cmd): # No subcommand was provided, so as called self.do_help('base') - # This makes sure correct tab completion functions are called based on the selected subcommand - complete_base = functools.partialmethod(cmd2.Cmd.cmd_with_subs_completer, base='base') + # functools.partialmethod was added in Python 3.4 + if sys.version_info >= (3, 4): + # This makes sure correct tab completion functions are called based on the selected subcommand + complete_base = functools.partialmethod(cmd2.Cmd.cmd_with_subs_completer, base='base') if __name__ == '__main__': |