File: test_decorators.py

package info (click to toggle)
python-pynvim 0.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 344 kB
  • sloc: python: 2,538; sh: 6; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 979 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from pynvim.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)
    assert '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)
    assert 'count' not in decorated._nvim_rpc_spec['opts']

    # Test presesence with value of 0
    count_value = 0
    decorated = command('test', count=count_value)(function)
    assert 'count' in decorated._nvim_rpc_spec['opts']
    assert decorated._nvim_rpc_spec['opts']['count'] == count_value

    # Test presence with value of 1
    count_value = 1
    decorated = command('test', count=count_value)(function)
    assert 'count' in decorated._nvim_rpc_spec['opts']
    assert decorated._nvim_rpc_spec['opts']['count'] == count_value