diff options
author | Eric Lin <anselor@gmail.com> | 2020-06-16 10:07:46 -0400 |
---|---|---|
committer | anselor <anselor@gmail.com> | 2020-08-04 13:38:08 -0400 |
commit | f995e7abdef961ec0813f749debb1cfef1f8989d (patch) | |
tree | 085c6ade996b9c66c322b505bb135b8d04321368 /tests | |
parent | 07321efc8ac8dc5d8276a1c33ed4fa506e24ae6a (diff) | |
download | cmd2-git-f995e7abdef961ec0813f749debb1cfef1f8989d.tar.gz |
Added explicit tests for dir and setattr. Minor type hinting changes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_commandset.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_commandset.py b/tests/test_commandset.py index 269c5de9..a4207f99 100644 --- a/tests/test_commandset.py +++ b/tests/test_commandset.py @@ -302,3 +302,27 @@ def test_command_functions(command_sets_manual): first_match = complete_tester(text, line, begidx, endidx, command_sets_manual) assert first_match is None + +def test_partial_with_passthru(): + + def test_func(arg1, arg2): + """Documentation Comment""" + print('Do stuff {} - {}'.format(arg1, arg2)) + + my_partial = cmd2.command_definition._partial_passthru(test_func, 1) + + setattr(test_func, 'Foo', 5) + + assert hasattr(my_partial, 'Foo') + + assert getattr(my_partial, 'Foo', None) == 5 + + a = dir(test_func) + b = dir(my_partial) + assert a == b + + assert not hasattr(test_func, 'Bar') + setattr(my_partial, 'Bar', 6) + assert hasattr(test_func, 'Bar') + + assert getattr(test_func, 'Bar', None) == 6 |