File: test_tabpage.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 (48 lines) | stat: -rw-r--r-- 1,431 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pytest


def test_windows(vim):
    vim.command('tabnew')
    vim.command('vsplit')
    assert list(vim.tabpages[0].windows) == [vim.windows[0]]
    assert list(vim.tabpages[1].windows) == [vim.windows[1], vim.windows[2]]
    assert vim.tabpages[1].window == vim.windows[1]
    vim.current.window = vim.windows[2]
    assert vim.tabpages[1].window == vim.windows[2]


def test_vars(vim):
    vim.current.tabpage.vars['python'] = [1, 2, {'3': 1}]
    assert vim.current.tabpage.vars['python'] == [1, 2, {'3': 1}]
    assert vim.eval('t:python') == [1, 2, {'3': 1}]
    assert vim.current.tabpage.vars.get('python') == [1, 2, {'3': 1}]

    del vim.current.tabpage.vars['python']
    with pytest.raises(KeyError):
        vim.current.tabpage.vars['python']
    assert vim.eval('exists("t:python")') == 0

    with pytest.raises(KeyError):
        del vim.current.tabpage.vars['python']

    assert vim.current.tabpage.vars.get('python', 'default') == 'default'


def test_valid(vim):
    vim.command('tabnew')
    tabpage = vim.tabpages[1]
    assert tabpage.valid
    vim.command('tabclose')
    assert not tabpage.valid


def test_number(vim):
    curnum = vim.current.tabpage.number
    vim.command('tabnew')
    assert vim.current.tabpage.number == curnum + 1
    vim.command('tabnew')
    assert vim.current.tabpage.number == curnum + 2


def test_repr(vim):
    assert repr(vim.current.tabpage) == "<Tabpage(handle=1)>"