當前位置: 首頁>>代碼示例>>Python>>正文


Python State.yank方法代碼示例

本文整理匯總了Python中Vintageous.state.State.yank方法的典型用法代碼示例。如果您正苦於以下問題:Python State.yank方法的具體用法?Python State.yank怎麽用?Python State.yank使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Vintageous.state.State的用法示例。


在下文中一共展示了State.yank方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Test_yank

# 需要導入模塊: from Vintageous.state import State [as 別名]
# 或者: from Vintageous.state.State import yank [as 別名]
class Test_yank(ViewTest):
    def setUp(self):
        super().setUp()
        sublime.set_clipboard('')
        registers._REGISTER_DATA = {}
        self.view.settings().erase('vintage')
        self.view.settings().erase('vintageous_use_sys_clipboard')
        self.regs = State(self.view).registers
        self.regs.view = mock.Mock()

    def testDontYankIfWeDontHaveTo(self):
        class vi_cmd_data:
            _can_yank = False
            _populates_small_delete_register = False

        self.regs.yank(vi_cmd_data)
        self.assertEqual(registers._REGISTER_DATA, {})

    def testYanksToUnnamedRegisterIfNoRegisterNameProvided(self):
        class vi_cmd_data:
            _can_yank = True
            _synthetize_new_line_at_eof = False
            _yanks_linewise = True
            register = None
            _populates_small_delete_register = False

        with mock.patch.object(self.regs, 'get_selected_text') as gst:
            gst.return_value = ['foo']
            self.regs.yank(vi_cmd_data)
            self.assertEqual(registers._REGISTER_DATA, {'"': ['foo']})

    def testYanksToRegisters(self):
        class vi_cmd_data:
            _can_yank = True
            _populates_small_delete_register = False

        with mock.patch.object(self.regs, 'get_selected_text') as gst:
            gst.return_value = ['foo']
            self.regs.yank(vi_cmd_data, register='a')
            self.assertEqual(registers._REGISTER_DATA, {'"': ['foo'], 'a': ['foo']})

    def testCanPopulateSmallDeleteRegister(self):
        class vi_cmd_data:
            _can_yank = True
            _populates_small_delete_register = True

        with mock.patch.object(builtins, 'all') as a, \
             mock.patch.object(self.regs, 'get_selected_text') as gst:
                gst.return_value = ['foo']
                self.regs.view.sel.return_value = range(1)
                a.return_value = True
                self.regs.yank(vi_cmd_data)
                self.assertEqual(registers._REGISTER_DATA, {'"': ['foo'], '-': ['foo']})

    def testDoesNotPopulateSmallDeleteRegisterIfWeShouldNot(self):
        class vi_cmd_data:
            _can_yank = False
            _populates_small_delete_register = False

        with mock.patch.object(builtins, 'all') as a, \
             mock.patch.object(self.regs, 'get_selected_text') as gst:
                gst.return_value = ['foo']
                self.regs.view.sel.return_value = range(1)
                a.return_value = False
                self.regs.yank(vi_cmd_data)
                self.assertEqual(registers._REGISTER_DATA, {})
開發者ID:TetragrammatonHermit,項目名稱:Vintageous,代碼行數:68,代碼來源:test_registers.py


注:本文中的Vintageous.state.State.yank方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。