-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #298 "check count for 'not None' instead of truthy"
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from nose.tools import with_setup, eq_ as eq, ok_ as ok | ||
|
||
from neovim.plugin.decorators import command | ||
|
||
|
||
def test_command_count(): | ||
def function(): | ||
"A dummy function to decorate." | ||
return | ||
|
||
# ensure absence with default value of None | ||
decorated = command('test')(function) | ||
ok('count' not in decorated._nvim_rpc_spec['opts']) | ||
|
||
# ensure absence with explicit value of None | ||
count_value = None | ||
decorated = command('test', count=count_value)(function) | ||
ok('count' not in decorated._nvim_rpc_spec['opts']) | ||
|
||
# Test presesence with value of 0 | ||
count_value = 0 | ||
decorated = command('test', count=count_value)(function) | ||
ok('count' in decorated._nvim_rpc_spec['opts']) | ||
eq(decorated._nvim_rpc_spec['opts']['count'], count_value) | ||
|
||
# Test presence with value of 1 | ||
count_value = 1 | ||
decorated = command('test', count=count_value)(function) | ||
ok('count' in decorated._nvim_rpc_spec['opts']) | ||
eq(decorated._nvim_rpc_spec['opts']['count'], count_value) |