コード例 #1
0
    def test_punctuation_retry(self):
        """
        Test that bot finds tags that don't
        match because of punctuation, but would
        match otherwise.

        e.g. In the string, "You should look at :h help."
        """

        bot = Bot()
        tags = [
            "'formatlistpat'", "g:var", "c_CTRL-SHIFT-V", ":lhelpgrep",
            ":viusage", "quote.", "+extra", ":import-cycle"
        ]
        punct = [',', '.', ';', ':'] * 2
        text = "Test comment: "
        for tag, punct in zip(tags, punct):
            text = text + " :h " + tag + punct

        reply = bot.create_comment(text, "vim")
        self.assertNotEqual(reply, '')
        for tag in tags:
            self.assertIn(tag, reply)

        reply = bot.create_comment(text, "neovim")
        self.assertNotEqual(reply, '')
        for tag in tags:
            self.assertIn(tag, reply)
コード例 #2
0
    def test_empty_comment(self):
        """
        Test comment is empty if nothing is found
        """
        bot = Bot()
        comment = "Test comment `:h nothingtoseehere`"

        reply = bot.create_comment(comment, "link", "vim")
        self.assertEqual(reply, '')

        reply = bot.create_comment(comment, "link", "neovim")
        self.assertEqual(reply, '')
コード例 #3
0
    def test_url_encoding(self):
        """
        Test that bot url encodes /
        """

        bot = Bot()
        reply = bot.create_comment("`:h s/\\0`", "vim")
        self.assertIn("https://vimhelp.org/change.txt.html#s%2F%5C0", reply)
コード例 #4
0
    def test_backtick_comment(self):
        """
        Test that bot can find all backtick-style queries
        """

        bot = Bot()
        tags = [
            ":tab", ":options", ":tjump", "c_CTRL-R_CTRL-W", ":execute",
            "expand()"
        ]

        text = "Test comment: " + \
            ','.join(list(map(lambda t: "`:h {}`".format(t), tags)))

        reply = bot.create_comment(text, "vim")
        self.assertNotEqual(reply, '')
        for tag in tags:
            self.assertIn(tag, reply)

        reply = bot.create_comment(text, "neovim")
        self.assertNotEqual(reply, '')
        for tag in tags:
            self.assertIn(tag, reply)
コード例 #5
0
    def test_mixed_style_comment(self):
        """
        Test that bot can find all backtick-
        and space- style queries when mixed
        """

        bot = Bot()
        backtick_tags = [":,", "'formatlistpat'", "augroup"]
        space_tags = ["l:var", "substitute()", "'updatetime'"]
        text = "Test comment: " + \
            ','.join(list(map(lambda t: "`:h {}`".format(t), backtick_tags))) + \
            '\n' + \
            ' '.join(list(map(lambda t: ":h {}".format(t), space_tags)))

        reply = bot.create_comment(text, "vim")
        self.assertNotEqual(reply, '')
        for tag in backtick_tags + space_tags:
            self.assertIn(tag, reply)

        reply = bot.create_comment(text, "neovim")
        self.assertNotEqual(reply, '')
        for tag in backtick_tags + space_tags:
            self.assertIn(tag, reply)