annotate src/testdir/test_python2.vim @ 16688:e791f29affae v8.1.1346

patch 8.1.1346: error for Python exception does not show useful info commit https://github.com/vim/vim/commit/7f3a28490abb7c495239fc438825e3d1aaafa76d Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 18 15:02:25 2019 +0200 patch 8.1.1346: error for Python exception does not show useful info Problem: Error for Python exception does not show useful info. Solution: Show the last line instead of the first one. (Ben Jackson, closes #4381)
author Bram Moolenaar <Bram@vim.org>
date Sat, 18 May 2019 15:15:05 +0200
parents 402b714cb919
children f38fcbf343ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10751
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for python 2 commands.
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " TODO: move tests from test87.in here.
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 if !has('python')
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 finish
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endif
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func Test_pydo()
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 " Check deleting lines does not trigger ml_get error.
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 py import vim
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 new
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call setline(1, ['one', 'two', 'three'])
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 pydo vim.command("%d_")
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 bwipe!
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 " Check switching to another buffer does not trigger ml_get error.
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 new
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let wincount = winnr('$')
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call setline(1, ['one', 'two', 'three'])
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 pydo vim.command("new")
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 call assert_equal(wincount + 1, winnr('$'))
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 bwipe!
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 bwipe!
27b42717662b patch 8.0.0265: may get ml_get error when :pydo deletes lines
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endfunc
14395
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
25
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
26 func Test_set_cursor()
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
27 " Check that setting the cursor position works.
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
28 py import vim
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
29 new
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
30 call setline(1, ['first line', 'second line'])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
31 normal gg
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
32 pydo vim.current.window.cursor = (1, 5)
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
33 call assert_equal([1, 6], [line('.'), col('.')])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
34
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
35 " Check that movement after setting cursor position keeps current column.
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
36 normal j
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
37 call assert_equal([2, 6], [line('.'), col('.')])
c15bef307de6 patch 8.1.0212: preferred cursor column not set in interfaces
Christian Brabandt <cb@256bit.org>
parents: 10751
diff changeset
38 endfunc
15234
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
39
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
40 func Test_vim_function()
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
41 " Check creating vim.Function object
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
42 py import vim
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
43
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
44 func s:foo()
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
45 return matchstr(expand('<sfile>'), '<SNR>\zs\d\+_foo$')
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
46 endfunc
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
47 let name = '<SNR>' . s:foo()
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
48
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
49 try
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
50 py f = vim.bindeval('function("s:foo")')
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
51 call assert_equal(name, pyeval('f.name'))
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
52 catch
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
53 call assert_false(v:exception)
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
54 endtry
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
55
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
56 try
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
57 py f = vim.Function('\x80\xfdR' + vim.eval('s:foo()'))
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
58 call assert_equal(name, pyeval('f.name'))
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
59 catch
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
60 call assert_false(v:exception)
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
61 endtry
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
62
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
63 py del f
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
64 delfunc s:foo
ee63f4fe3d45 patch 8.1.0627: Python cannot handle function name of script-local function
Bram Moolenaar <Bram@vim.org>
parents: 14395
diff changeset
65 endfunc
15888
a83c4b1f8ea2 patch 8.1.0950: using :python sets 'pyxversion' even when not executed
Bram Moolenaar <Bram@vim.org>
parents: 15234
diff changeset
66
a83c4b1f8ea2 patch 8.1.0950: using :python sets 'pyxversion' even when not executed
Bram Moolenaar <Bram@vim.org>
parents: 15234
diff changeset
67 func Test_skipped_python_command_does_not_affect_pyxversion()
a83c4b1f8ea2 patch 8.1.0950: using :python sets 'pyxversion' even when not executed
Bram Moolenaar <Bram@vim.org>
parents: 15234
diff changeset
68 set pyxversion=0
a83c4b1f8ea2 patch 8.1.0950: using :python sets 'pyxversion' even when not executed
Bram Moolenaar <Bram@vim.org>
parents: 15234
diff changeset
69 if 0
a83c4b1f8ea2 patch 8.1.0950: using :python sets 'pyxversion' even when not executed
Bram Moolenaar <Bram@vim.org>
parents: 15234
diff changeset
70 python import vim
a83c4b1f8ea2 patch 8.1.0950: using :python sets 'pyxversion' even when not executed
Bram Moolenaar <Bram@vim.org>
parents: 15234
diff changeset
71 endif
a83c4b1f8ea2 patch 8.1.0950: using :python sets 'pyxversion' even when not executed
Bram Moolenaar <Bram@vim.org>
parents: 15234
diff changeset
72 call assert_equal(0, &pyxversion) " This assertion would have failed with Vim 8.0.0251. (pyxversion was introduced in 8.0.0251.)
a83c4b1f8ea2 patch 8.1.0950: using :python sets 'pyxversion' even when not executed
Bram Moolenaar <Bram@vim.org>
parents: 15234
diff changeset
73 endfunc
16080
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
74
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
75 func _SetUpHiddenBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
76 py import vim
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
77 new
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
78 edit hidden
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
79 setlocal bufhidden=hide
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
80
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
81 enew
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
82 let lnum = 0
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
83 while lnum < 10
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
84 call append( 1, string( lnum ) )
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
85 let lnum = lnum + 1
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
86 endwhile
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
87 normal G
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
88
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
89 call assert_equal( line( '.' ), 11 )
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
90 endfunc
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
91
16138
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
92 func _CleanUpHiddenBuffer()
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
93 bwipe! hidden
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
94 bwipe!
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
95 endfunc
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
96
16080
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
97 func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Clear()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
98 call _SetUpHiddenBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
99 py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][:] = None
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
100 call assert_equal( line( '.' ), 11 )
16138
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
101 call _CleanUpHiddenBuffer()
16080
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
102 endfunc
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
103
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
104 func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_List()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
105 call _SetUpHiddenBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
106 py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][:] = [ 'test' ]
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
107 call assert_equal( line( '.' ), 11 )
16138
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
108 call _CleanUpHiddenBuffer()
16080
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
109 endfunc
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
110
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
111 func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Str()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
112 call _SetUpHiddenBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
113 py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][0] = 'test'
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
114 call assert_equal( line( '.' ), 11 )
16138
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
115 call _CleanUpHiddenBuffer()
16080
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
116 endfunc
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
117
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
118 func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_ClearLine()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
119 call _SetUpHiddenBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
120 py vim.buffers[ int( vim.eval( 'bufnr("hidden")' ) ) ][0] = None
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
121 call assert_equal( line( '.' ), 11 )
16138
402b714cb919 patch 8.1.1074: Python test doesn't wipe out hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 16080
diff changeset
122 call _CleanUpHiddenBuffer()
16080
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
123 endfunc
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
124
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
125 func _SetUpVisibleBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
126 py import vim
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
127 new
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
128 let lnum = 0
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
129 while lnum < 10
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
130 call append( 1, string( lnum ) )
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
131 let lnum = lnum + 1
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
132 endwhile
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
133 normal G
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
134 call assert_equal( line( '.' ), 11 )
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
135 endfunc
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
136
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
137 func Test_Write_To_Current_Buffer_Fixes_Cursor_Clear()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
138 call _SetUpVisibleBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
139
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
140 py vim.current.buffer[:] = None
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
141 call assert_equal( line( '.' ), 1 )
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
142
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
143 bwipe!
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
144 endfunc
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
145
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
146 func Test_Write_To_Current_Buffer_Fixes_Cursor_List()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
147 call _SetUpVisibleBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
148
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
149 py vim.current.buffer[:] = [ 'test' ]
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
150 call assert_equal( line( '.' ), 1 )
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
151
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
152 bwipe!
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
153 endfunction
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
154
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
155 func Test_Write_To_Current_Buffer_Fixes_Cursor_Str()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
156 call _SetUpVisibleBuffer()
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
157
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
158 py vim.current.buffer[-1] = None
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
159 call assert_equal( line( '.' ), 10 )
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
160
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
161 bwipe!
bf8cf5c3b784 patch 8.1.1045: E315 ml_get error when using Python and hidden buffer
Bram Moolenaar <Bram@vim.org>
parents: 15888
diff changeset
162 endfunction
16688
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 16138
diff changeset
163
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 16138
diff changeset
164 func Test_Catch_Exception_Message()
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 16138
diff changeset
165 try
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 16138
diff changeset
166 py raise RuntimeError( 'TEST' )
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 16138
diff changeset
167 catch /.*/
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 16138
diff changeset
168 call assert_match( '^Vim(.*):RuntimeError: TEST$', v:exception )
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 16138
diff changeset
169 endtry
e791f29affae patch 8.1.1346: error for Python exception does not show useful info
Bram Moolenaar <Bram@vim.org>
parents: 16138
diff changeset
170 endfunc