File: test_Fixes.py

package info (click to toggle)
vim-ultisnips 3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,924 kB
  • sloc: python: 8,353; sh: 64; makefile: 38
file content (107 lines) | stat: -rw-r--r-- 2,807 bytes parent folder | download | duplicates (2)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from test.vim_test_case import VimTestCase as _VimTest
from test.constant import *


class Bug1251994(_VimTest):
    snippets = ("test", "${2:#2} ${1:#1};$0")
    keys = "  test" + EX + "hello" + JF + "world" + JF + "blub"
    wanted = "  world hello;blub"


# Test for https://github.com/SirVer/ultisnips/issues/157 (virtualedit)


class VirtualEdit(_VimTest):
    snippets = ("pd", "padding: ${1:0}px")
    keys = "\t\t\tpd" + EX + "2"
    wanted = "\t\t\tpadding: 2px"

    def _extra_vim_config(self, vim_config):
        vim_config.append("set virtualedit=all")
        vim_config.append("set noexpandtab")


# End: 1251994

# Test for Github Pull Request #134 - Retain unnamed register


class RetainsTheUnnamedRegister(_VimTest):
    snippets = ("test", "${1:hello} ${2:world} ${0}")
    keys = "yank" + ESC + "by4lea test" + EX + "HELLO" + JF + JF + ESC + "p"
    wanted = "yank HELLO world yank"


class RetainsTheUnnamedRegister_ButOnlyOnce(_VimTest):
    snippets = ("test", "${1:hello} ${2:world} ${0}")
    keys = (
        "blahfasel"
        + ESC
        + "v"
        + 4 * ARR_L
        + "xotest"
        + EX
        + ESC
        + ARR_U
        + "v0xo"
        + ESC
        + "p"
    )
    wanted = "\nblah\nhello world "


# End: Github Pull Request # 134

# Test to ensure that shiftwidth follows tabstop when it's set to zero post
# version 7.3.693. Prior to that version a shiftwidth of zero effectively
# removes tabs.


class ShiftWidthZero(_VimTest):
    def _extra_vim_config(self, vim_config):
        vim_config += ["if exists('*shiftwidth')", "  set shiftwidth=0", "endif"]

    snippets = ("test", "\t${1}${0}")
    keys = "test" + EX + "foo"
    wanted = "\tfoo"


# Test for https://github.com/SirVer/ultisnips/issues/171
# Make sure that we don't crash when trying to save and restore the clipboard
# when it contains data that we can't coerce into Unicode.


class NonUnicodeDataInUnnamedRegister(_VimTest):
    snippets = ("test", "hello")
    keys = (
        "test"
        + EX
        + ESC
        + "\n".join(
            [
                ":redir @a",
                ":messages",
                ":redir END",
                (
                    ":if match(@a, 'Error') != -1 | "
                    + "call setline('.', 'error detected') | "
                    + "3put a | "
                    + "endif"
                ),
                "",
            ]
        )
    )
    wanted = "hello"

    def _before_test(self):
        # The string below was the one a user had on their clipboard when
        # encountering the UnicodeDecodeError and could not be coerced into
        # unicode.
        self.vim.send_to_vim(
            ':let @" = "\\x80kdI{\\x80@7 1},'
            + '\\x80kh\\x80kh\\x80kd\\x80kdq\\x80kb\\x1b"\n'
        )


# End: #171