robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1" Test for python 3 commands. 2 3source check.vim 4CheckFeature python3 5 6" This function should be called first. This sets up python functions used by 7" the other tests. 8func Test_AAA_python3_setup () 9py 3 << trim EOF 10import vim 11import sys 12import re 13 14py 33_ type_error_pattern = re .compile (r'^__call__\(\) takes (\d+) positional argument but (\d+) were given$' ) 15py 37_ exception_repr = re .compile (r'([^\(\),])(\)+)$' ) 16py 39_ type_error_pattern = re .compile (r'\w+\.([^(]+\(\) takes)' ) 17py 310_ type_error_pattern = re .compile (r'takes (\d+) positional argument but (\d+) were given' ) 18py 314_ type_error_tuple_pattern = re .compile (r'must be (\d+)-item tuple' ) 19 20def emsg(ei): 21return ei [ 0 ]. __name__ + ':' + repr ( ei [ 1 ]. args ) 22 23def ee(expr, g=globals(), l=locals()): 24cb = vim.current.buffer 25try : 26try : 27exec ( expr , g, l) 28except Exception as e: 29if sys . version_info >= ( 3 , 3) and e.__class__ isAttributeError and str(e).find('has no attribute')>=0 and not str(e).startswith("'vim."): 30msg = repr((e.__class__, AttributeError(str(e)[str(e).rfind(" '") + 2:-1]))) 31elif sys.version_info >= (3, 3) and e.__class__ is ImportError and str(e).find('No module named \'') >= 0: 32msg = repr((e.__class__, ImportError(str(e).replace("'",'' )))) 33elif sys.version_info >= (3, 6) and e.__class__ is ModuleNotFoundError: 34 #Python 3.6 givesModuleNotFoundError, change it to anImportError 35msg = repr((ImportError, ImportError(str(e).replace("'",'' )))) 36elif sys.version_info >= (3, 3) and e.__class__ is TypeError: 37m = py33_type_error_pattern.search(str(e)) 38if m : 39msg ='__call__() takes exactly {0} positional argument ({1} given)' .format(m.group(1), m.group(2)) 40msg = repr((e.__class__, TypeError(msg))) 41else : 42msg = repr((e.__class__, e)) 43 #Messages changed withPython 3.6, change new to old. 44newmsg 1 ="""'argument must be str, bytes or bytearray, not None'""" 45oldmsg 1 ='''"Can' t convert'NoneType' object to str implicitly"''' 46if msg . find ( newmsg1 ) > -1 : 47msg = msg.replace(newmsg1, oldmsg1) 48newmsg 2 ="""'argument must be str, bytes or bytearray, not int'""" 49oldmsg 2 ='''"Can' t convert'int' object to str implicitly"''' 50if msg . find ( newmsg2 ) > -1 : 51msg = msg.replace(newmsg2, oldmsg2) 52 #Python 3.9 reports errors like "vim.command () takes ..." instead of "command () takes ..." 53msg = py39_type_error_pattern.sub(r'\1', msg) 54msg = py310_type_error_pattern.sub(r'takes exactly \1 positional argument (\2 given)', msg) 55 #Python 3.14 has specific error messages forTuple's 56msg = py314_type_error_tuple_pattern.sub(r'must be \1-item sequence', msg) 57elif sys.version_info >= (3, 5) and e.__class__ is ValueError and str(e) =='embedded null byte' : 58msg = repr((TypeError, TypeError('expected bytes with no null'))) 59else : 60msg = repr((e.__class__, e)) 61 #Some Python versions say can't, others cannot. 62if msg . find ( 'can\' t') > -1: 63msg = msg.replace('can\'t','cannot' ) 64 #Some Python versions use single quote, some double quote 65if msg . find ( '"cannot ' ) > -1 : 66msg = msg.replace('"cannot', ' \'cannot ') 67if msg . find ( ' attributes"' ) > -1 : 68msg = msg.replace(' attributes"', ' attributes\'') 69if sys . version_info >= ( 3 , 7): 70msg = py37_exception_repr.sub(r'\1,\2', msg) 71cb .append(expr +':' + msg) 72else : 73cb .append(expr +':NOT FAILED' ) 74except Exception as e: 75msg = repr((e.__class__, e)) 76if sys . version_info >= ( 3 , 7): 77msg = py37_exception_repr.sub(r'\1,\2', msg) 78cb .append(expr +'::' + msg) 79EOF 80endfunc 81 82func Test_py3do () 83" Check deleting lines does not trigger an ml_get error. 84py 3 import vim 85new 86call setline ( 1 , [ 'one' , 'two' , 'three' ]) 87py 3 do vim .command ("%d_" ) 88bwipe ! 89 90" Disabled until neovim/neovim#8554 is resolved 91if 0 92" Check switching to another buffer does not trigger an ml_get error. 93new 94let wincount = winnr ( '$' ) 95call setline ( 1 , [ 'one' , 'two' , 'three' ]) 96py 3 do vim .command ("new" ) 97call assert_equal ( wincount + 1 , winnr ( '$' )) 98bwipe ! 99bwipe ! 100endif 101endfunc 102 103func Test_set_cursor () 104" Check that setting the cursor position works. 105py 3 import vim 106new 107call setline ( 1 , [ 'first line' , 'second line' ]) 108normal gg 109py 3 do vim .current .window .cursor = (1 ,5 ) 110call assert_equal ([ 1 , 6 ], [ line ( '.' ), col ( '.' )]) 111 112" Check that movement after setting cursor position keeps current column. 113normal j 114call assert_equal ([ 2 , 6 ], [ line ( '.' ), col ( '.' )]) 115endfunc 116 117func Test_vim_function () 118throw 'Skipped: Nvim does not support vim.bindeval()' 119" Check creating vim.Function object 120py 3 import vim 121 122func s: foo () 123return matchstr ( expand ( '<sfile>' ), '<SNR>\zs\d\+_foo$' ) 124endfunc 125let name = '<SNR>' . s: foo () 126 127try 128py 3 f = vim .bindeval ('function("s:foo")' ) 129call assert_equal ( name , py3eval ( 'f.name' )) 130catch 131call assert_false ( v: exception ) 132endtry 133 134try 135py 3 f = vim .Function (b'\x80\xfdR' + vim .eval ('s:foo()' ).encode ()) 136call assert_equal ( name , 'f.name' ->py3eval ()) 137catch 138call assert_false ( v: exception ) 139endtry 140 141let caught_vim_err = v: false 142try 143let x = py3eval ( 'f.abc' ) 144catch 145call assert_match ( "AttributeError: 'vim.function' object has no attribute 'abc'" , v: exception ) 146let caught_vim_err = v: true 147endtry 148call assert_equal ( v: true , caught_vim_err ) 149 150py 3 del f 151delfunc s:foo 152endfunc 153 154func Test_skipped_python3_command_does_not_affect_pyxversion () 155throw 'Skipped: Nvim hardcodes pyxversion=3' 156set pyxversion = 0 157if 0 158python 3 import vim 159endif 160call assert_equal ( 0 , & pyxversion ) " This assertion would have failed with Vim 8.0.0251. (pyxversion was introduced in 8.0.0251.) 161endfunc 162 163func _SetUpHiddenBuffer () 164py 3 import vim 165new 166edit hidden 167setlocal bufhidden = hide 168 169enew 170let lnum = 0 171while lnum < 10 172call append ( 1 , string ( lnum ) ) 173let lnum = lnum + 1 174endwhile 175normal G 176 177call assert_equal ( line ( '.' ), 11 ) 178endfunc 179 180func _CleanUpHiddenBuffer () 181bwipe ! hidden 182bwipe ! 183endfunc 184 185func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Clear () 186call _SetUpHiddenBuffer () 187py 3 vim .buffers [int (vim .eval ('bufnr("hidden")' ) ) ][:]= None 188call assert_equal ( line ( '.' ), 11 ) 189call _CleanUpHiddenBuffer () 190endfunc 191 192func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_List () 193call _SetUpHiddenBuffer () 194py 3 vim .buffers [int (vim .eval ('bufnr("hidden")' ) ) ][:]= ['test' ] 195call assert_equal ( line ( '.' ), 11 ) 196call _CleanUpHiddenBuffer () 197endfunc 198 199func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_Str () 200call _SetUpHiddenBuffer () 201py 3 vim .buffers [int (vim .eval ('bufnr("hidden")' ) ) ][0 ]= 'test' 202call assert_equal ( line ( '.' ), 11 ) 203call _CleanUpHiddenBuffer () 204endfunc 205 206func Test_Write_To_HiddenBuffer_Does_Not_Fix_Cursor_ClearLine () 207call _SetUpHiddenBuffer () 208py 3 vim .buffers [int (vim .eval ('bufnr("hidden")' ) ) ][0 ]= None 209call assert_equal ( line ( '.' ), 11 ) 210call _CleanUpHiddenBuffer () 211endfunc 212 213func _SetUpVisibleBuffer () 214py 3 import vim 215new 216let lnum = 0 217while lnum < 10 218call append ( 1 , string ( lnum ) ) 219let lnum = lnum + 1 220endwhile 221normal G 222call assert_equal ( line ( '.' ), 11 ) 223endfunc 224 225func Test_Write_To_Current_Buffer_Fixes_Cursor_Clear () 226call _SetUpVisibleBuffer () 227 228py 3 vim .current .buffer [:]= None 229call assert_equal ( line ( '.' ), 1 ) 230 231bwipe ! 232endfunc 233 234func Test_Write_To_Current_Buffer_Fixes_Cursor_List () 235call _SetUpVisibleBuffer () 236 237py 3 vim .current .buffer [:]= ['test' ] 238call assert_equal ( line ( '.' ), 1 ) 239 240bwipe ! 241endfunc 242 243func Test_Write_To_Current_Buffer_Fixes_Cursor_Str () 244call _SetUpVisibleBuffer () 245 246py 3 vim .current .buffer [- 1 ]= None 247call assert_equal ( line ( '.' ), 10 ) 248 249bwipe ! 250endfunc 251 252func Test_Catch_Exception_Message () 253try 254py 3 raise RuntimeError ('TEST' ) 255catch /.*/ 256call assert_match ( '^Vim(.*):.*RuntimeError: TEST.*$' , v: exception ) 257endtry 258endfunc 259 260func Test_unicode () 261" this crashed Vim once 262throw "Skipped: nvim does not support changing 'encoding'" 263 264set encoding = utf32 265py 3 'hello' ) 266 267if ! has ( 'win32' ) 268set encoding = debug 269py 3 'hello' ) 270 271set encoding = euc-tw 272py 3 'hello' ) 273endif 274 275set encoding = utf8 276endfunc 277 278" Test vim.eval() with various types. 279func Test_python3_vim_eval () 280call assert_equal ( "\n2061300532912" , execute ( 'py3 print(vim.eval("2061300532912"))' )) 281call assert_equal ( "\n9223372036854775807" , execute ( 'py3 print(vim.eval("9223372036854775807"))' )) 282call assert_equal ( "\n-9223372036854775807" , execute ( 'py3 print(vim.eval("-9223372036854775807"))' )) 283call assert_equal ( "\n2147483648" , execute ( 'py3 print(vim.eval("2147483648"))' )) 284call assert_equal ( "\n-2147483649" , execute ( 'py3 print(vim.eval("-2147483649"))' )) 285call assert_equal ( "\n8" , execute ( 'py3 print(vim.eval("3+5"))' )) 286if has ( 'float' ) 287call assert_equal ( "\n3.1399999999999997" , execute ( 'py3 print(vim.eval("1.01+2.13"))' )) 288call assert_equal ( "\n0.0" , execute ( 'py3 print(vim.eval("0.0/(1.0/0.0)"))' )) 289call assert_equal ( "\n0.0" , execute ( 'py3 print(vim.eval("0.0/(1.0/0.0)"))' )) 290call assert_equal ( "\n-0.0" , execute ( 'py3 print(vim.eval("0.0/(-1.0/0.0)"))' )) 291" Commented out: output of infinity and nan depend on platforms. 292" call assert_equal("\ninf", execute('py3 print(vim.eval("1.0/0.0"))')) 293" call assert_equal("\n-inf", execute('py3 print(vim.eval("-1.0/0.0"))')) 294" call assert_equal("\n-nan", execute('py3 print(vim.eval("0.0/0.0"))')) 295endif 296call assert_equal ( "\nabc" , execute ( 'py3 print(vim.eval("\"abc\""))' )) 297call assert_equal ( "\n['1', '2']" , execute ( 'py3 print(vim.eval("[1, 2]"))' )) 298call assert_equal ( "\n{'1': '2'}" , execute ( 'py3 print(vim.eval("{1:2}"))' )) 299call assert_equal ( "\nTrue" , execute ( 'py3 print(vim.eval("v:true"))' )) 300call assert_equal ( "\nFalse" , execute ( 'py3 print(vim.eval("v:false"))' )) 301call assert_equal ( "\nNone" , execute ( 'py3 print(vim.eval("v:null"))' )) 302" call assert_equal("\nNone", execute('py3 print(vim.eval("v:none"))')) 303" call assert_equal("\nb'\\xab\\x12'", execute('py3 print(vim.eval("0zab12"))')) 304 305call assert_fails ( 'py3 vim.eval("1+")' , 'E5108:' ) 306endfunc 307 308" Test for resetting options with local values to global values 309func Test_python3_opt_reset_local_to_global () 310throw 'Skipped: Nvim does not support vim.bindeval()' 311new 312 313py 3 curbuf = vim .current .buffer 314py 3 curwin = vim .current .window 315 316" List of buffer-local options. Each list item has [option name, global 317" value, buffer-local value, buffer-local value after reset] to use in the 318" test. 319let bopts = [ 320 \[ 'autoread' , 1 , 0 , -1 ], 321 \[ 'equalprg' , 'geprg' , 'leprg' , '' ], 322 \[ 'keywordprg' , 'gkprg' , 'lkprg' , '' ], 323 \[ 'path' , 'gpath' , 'lpath' , '' ], 324 \[ 'backupcopy' , 'yes' , 'no' , '' ], 325 \[ 'tags' , 'gtags' , 'ltags' , '' ], 326 \[ 'tagcase' , 'ignore' , 'match' , '' ], 327 \[ 'define' , 'gdef' , 'ldef' , '' ], 328 \[ 'include' , 'ginc' , 'linc' , '' ], 329 \[ 'dict' , 'gdict' , 'ldict' , '' ], 330 \[ 'thesaurus' , 'gtsr' , 'ltsr' , '' ], 331 \[ 'formatprg' , 'gfprg' , 'lfprg' , '' ], 332 \[ 'errorformat' , '%f:%l:%m' , '%s-%l-%m' , '' ], 333 \[ 'grepprg' , 'ggprg' , 'lgprg' , '' ], 334 \[ 'makeprg' , 'gmprg' , 'lmprg' , '' ], 335 \[ 'balloonexpr' , 'gbexpr' , 'lbexpr' , '' ], 336 \[ 'cryptmethod' , 'blowfish2' , 'zip' , '' ], 337 \[ 'lispwords' , 'abc' , 'xyz' , '' ], 338 \[ 'makeencoding' , 'utf-8' , 'latin1' , '' ], 339 \[ 'undolevels' , 100 , 200 , -123456 ]] 340 341" Set the global and buffer-local option values and then clear the 342" buffer-local option value. 343for opt in bopts 344py 3 << trim END 345pyopt = vim.bindeval("opt") 346vim .options[pyopt[0]] = pyopt[1] 347curbuf .options[pyopt[0]] = pyopt[2] 348END 349exe "call assert_equal(opt[2], &" .. opt [ 0 ] .. ")" 350exe "call assert_equal(opt[1], &g:" .. opt [ 0 ] .. ")" 351exe "call assert_equal(opt[2], &l:" .. opt [ 0 ] .. ")" 352py 3 del curbuf .options [pyopt [0 ]] 353exe "call assert_equal(opt[1], &" .. opt [ 0 ] .. ")" 354exe "call assert_equal(opt[1], &g:" .. opt [ 0 ] .. ")" 355exe "call assert_equal(opt[3], &l:" .. opt [ 0 ] .. ")" 356exe "set " .. opt [ 0 ] .. "&" 357endfor 358 359" Set the global and window-local option values and then clear the 360" window-local option value. 361let wopts = [ 362 \[ 'scrolloff' , 5 , 10 , -1 ], 363 \[ 'sidescrolloff' , 6 , 12 , -1 ], 364 \[ 'statusline' , '%<%f' , '%<%F' , '' ]] 365for opt in wopts 366py 3 << trim 367pyopt = vim.bindeval("opt") 368vim .options[pyopt[0]] = pyopt[1] 369curwin .options[pyopt[0]] = pyopt[2] 370 . 371exe "call assert_equal(opt[2], &" .. opt [ 0 ] .. ")" 372exe "call assert_equal(opt[1], &g:" .. opt [ 0 ] .. ")" 373exe "call assert_equal(opt[2], &l:" .. opt [ 0 ] .. ")" 374py 3 del curwin .options [pyopt [0 ]] 375exe "call assert_equal(opt[1], &" .. opt [ 0 ] .. ")" 376exe "call assert_equal(opt[1], &g:" .. opt [ 0 ] .. ")" 377exe "call assert_equal(opt[3], &l:" .. opt [ 0 ] .. ")" 378exe "set " .. opt [ 0 ] .. "&" 379endfor 380 381close ! 382endfunc 383 384" Test for various heredoc syntax 385func Test_python3_heredoc () 386python 3 << END 387s ='A' 388END 389python 3 << 390s +='B' 391. 392python 3 << trim END 393s +='C' 394END 395python 3 << trim 396s +='D' 397 . 398python 3 << trim eof 399s +='E' 400eof 401python 3 << trimm 402s +='F' 403trimm 404call assert_equal ( 'ABCDEF' , pyxeval ( 's' )) 405endfunc 406 407" Test for the python List object 408func Test_python3_list () 409throw 'Skipped: Nvim does not support vim.bindeval()' 410let l = [] 411py 3 l = vim .bindeval ('l' ) 412py 3 f = vim .bindeval ('function("strlen")' ) 413" Extending List directly with different types 414py 3 l += [1 ,"as'd" , [1 ,2 ,f , {'a' :1 }]] 415call assert_equal ([ 1 , "as'd" , [ 1 , 2 , function ( "strlen" ), { 'a' : 1 }]], l ) 416call assert_equal ([ 1 , 2 , function ( "strlen" ), { 'a' : 1 }], l [ -1 ]) 417call assert_fails ( 'echo l[-4]' , 'E684:' ) 418 419" List assignment 420py 3 l [0 ]= 0 421call assert_equal ([ 0 , "as'd" , [ 1 , 2 , function ( "strlen" ), { 'a' : 1 }]], l ) 422py 3 l [- 2 ]= f 423call assert_equal ([ 0 , function ( "strlen" ), [ 1 , 2 , function ( "strlen" ), { 'a' : 1 }]], l ) 424endfunc 425 426" Extending Dictionary directly with different types 427func Test_python3_dict_extend () 428throw 'Skipped: Nvim does not support vim.bindeval()' 429let d = {} 430func d . f () 431return 1 432endfunc 433 434py 3 f = vim .bindeval ('function("strlen")' ) 435py 3 << trim EOF 436d = vim.bindeval('d') 437d ['1'] ='asd' 438d .update() # Must not do anything, including throwing errors 439d .update(b = [1, 2, f]) 440d .update((('-1', {'a': 1}),)) 441d .update({'0': -1}) 442dk = d.keys() 443dv = d.values() 444di = d.items() 445dk .sort(key=repr) 446dv .sort(key=repr) 447di .sort(key=repr) 448EOF 449 450call assert_equal ( 1 , py3eval ( "d['f'](self={})" )) 451call assert_equal ( "[b'-1', b'0', b'1', b'b', b'f']" , py3eval ( 'repr(dk)' )) 452call assert_equal ( "[-1, <vim.Function '1'>, <vim.dictionary object at >, <vim.list object at >, b'asd']" , substitute ( py3eval ( 'repr(dv)' ), '0x\x\+' , '' , 'g' )) 453call assert_equal ( "[(b'-1', <vim.dictionary object at >), (b'0', -1), (b'1', b'asd'), (b'b', <vim.list object at >), (b'f', <vim.Function '1'>)]" , substitute ( py3eval ( 'repr(di)' ), '0x\x\+' , '' , 'g' )) 454call assert_equal ([ '0' , '1' , 'b' , 'f' , '-1' ], keys ( d )) 455call assert_equal ( "[-1, 'asd', [1, 2, function('strlen')], function('1'), {'a': 1}]" , string ( values ( d ))) 456py 3 del dk 457py 3 del di 458py 3 del dv 459endfunc 460 461func Test_python3_list_del_items () 462throw 'Skipped: Nvim does not support vim.bindeval()' 463" removing items with del 464let l = [ 0 , function ( "strlen" ), [ 1 , 2 , function ( "strlen" ), { 'a' : 1 }]] 465py 3 l = vim .bindeval ('l' ) 466py 3 del l [2 ] 467call assert_equal ( "[0, function('strlen')]" , string ( l )) 468 469let l = range ( 8 ) 470py 3 l = vim .bindeval ('l' ) 471py 3 del l [:3 ] 472py 3 del l [1 :] 473call assert_equal ([ 3 ], l ) 474 475" removing items out of range: silently skip items that don't exist 476 477" The following two ranges delete nothing as they match empty list: 478let l = [ 0 , 1 , 2 , 3 ] 479py 3 l = vim .bindeval ('l' ) 480py 3 del l [2 :1 ] 481call assert_equal ([ 0 , 1 , 2 , 3 ], l ) 482py 3 del l [2 :2 ] 483call assert_equal ([ 0 , 1 , 2 , 3 ], l ) 484py 3 del l [2 :3 ] 485call assert_equal ([ 0 , 1 , 3 ], l ) 486 487let l = [ 0 , 1 , 2 , 3 ] 488py 3 l = vim .bindeval ('l' ) 489py 3 del l [2 :4 ] 490call assert_equal ([ 0 , 1 ], l ) 491 492let l = [ 0 , 1 , 2 , 3 ] 493py 3 l = vim .bindeval ('l' ) 494py 3 del l [2 :5 ] 495call assert_equal ([ 0 , 1 ], l ) 496 497let l = [ 0 , 1 , 2 , 3 ] 498py 3 l = vim .bindeval ('l' ) 499py 3 del l [2 :6 ] 500call assert_equal ([ 0 , 1 ], l ) 501 502" The following two ranges delete nothing as they match empty list: 503let l = [ 0 , 1 , 2 , 3 ] 504py 3 l = vim .bindeval ('l' ) 505py 3 del l [- 1 :2 ] 506call assert_equal ([ 0 , 1 , 2 , 3 ], l ) 507py 3 del l [- 2 :2 ] 508call assert_equal ([ 0 , 1 , 2 , 3 ], l ) 509py 3 del l [- 3 :2 ] 510call assert_equal ([ 0 , 2 , 3 ], l ) 511 512let l = [ 0 , 1 , 2 , 3 ] 513py 3 l = vim .bindeval ('l' ) 514py 3 del l [- 4 :2 ] 515call assert_equal ([ 2 , 3 ], l ) 516 517let l = [ 0 , 1 , 2 , 3 ] 518py 3 l = vim .bindeval ('l' ) 519py 3 del l [- 5 :2 ] 520call assert_equal ([ 2 , 3 ], l ) 521 522let l = [ 0 , 1 , 2 , 3 ] 523py 3 l = vim .bindeval ('l' ) 524py 3 del l [- 6 :2 ] 525call assert_equal ([ 2 , 3 ], l ) 526 527let l = [ 0 , 1 , 2 , 3 ] 528py 3 l = vim .bindeval ('l' ) 529py 3 del l [::2 ] 530call assert_equal ([ 1 , 3 ], l ) 531 532let l = [ 0 , 1 , 2 , 3 ] 533py 3 l = vim .bindeval ('l' ) 534py 3 del l [3 :0 :- 2 ] 535call assert_equal ([ 0 , 2 ], l ) 536 537let l = [ 0 , 1 , 2 , 3 ] 538py 3 l = vim .bindeval ('l' ) 539py 3 del l [2 :4 :- 2 ] 540let l = [ 0 , 1 , 2 , 3 ] 541endfunc 542 543func Test_python3_dict_del_items () 544throw 'Skipped: Nvim does not support vim.bindeval()' 545let d = eval ( "{'0' : -1, '1' : 'asd', 'b' : [1, 2, function('strlen')], 'f' : function('min'), '-1' : {'a': 1}}" ) 546py 3 d = vim .bindeval ('d' ) 547py 3 del d ['-1' ] 548py 3 del d ['f' ] 549call assert_equal ([ 1 , 2 , function ( 'strlen' )], py3eval ( 'd.get(''b'', 1)' )) 550call assert_equal ([ 1 , 2 , function ( 'strlen' )], py3eval ( 'd.pop(''b'')' )) 551call assert_equal ( 1 , py3eval ( 'd.get(''b'', 1)' )) 552call assert_equal ( 'asd' , py3eval ( 'd.pop(''1'', 2)' )) 553call assert_equal ( 2 , py3eval ( 'd.pop(''1'', 2)' )) 554call assert_equal ( 'True' , py3eval ( 'repr(d.has_key(''0''))' )) 555call assert_equal ( 'False' , py3eval ( 'repr(d.has_key(''1''))' )) 556call assert_equal ( 'True' , py3eval ( 'repr(''0'' in d)' )) 557call assert_equal ( 'False' , py3eval ( 'repr(''1'' in d)' )) 558call assert_equal ( "[b'0']" , py3eval ( 'repr(list(iter(d)))' )) 559call assert_equal ({ '0' : -1 }, d ) 560call assert_equal ( "(b'0', -1)" , py3eval ( 'repr(d.popitem())' )) 561call assert_equal ( 'None' , py3eval ( 'repr(d.get(''0''))' )) 562call assert_equal ( '[]' , py3eval ( 'repr(list(iter(d)))' )) 563endfunc 564 565" Slice assignment to a list 566func Test_python3_slice_assignment () 567throw 'Skipped: Nvim does not support vim.bindeval()' 568let l = [ 0 , 1 , 2 , 3 ] 569py 3 l = vim .bindeval ('l' ) 570py 3 l [0 :0 ]= ['a' ] 571call assert_equal ([ 'a' , 0 , 1 , 2 , 3 ], l ) 572 573let l = [ 0 , 1 , 2 , 3 ] 574py 3 l = vim .bindeval ('l' ) 575py 3 l [1 :2 ]= ['b' ] 576call assert_equal ([ 0 , 'b' , 2 , 3 ], l ) 577 578let l = [ 0 , 1 , 2 , 3 ] 579py 3 l = vim .bindeval ('l' ) 580py 3 l [2 :4 ]= ['c' ] 581call assert_equal ([ 0 , 1 , 'c' ], l ) 582 583let l = [ 0 , 1 , 2 , 3 ] 584py 3 l = vim .bindeval ('l' ) 585py 3 l [4 :4 ]= ['d' ] 586call assert_equal ([ 0 , 1 , 2 , 3 , 'd' ], l ) 587 588let l = [ 0 , 1 , 2 , 3 ] 589py 3 l = vim .bindeval ('l' ) 590py 3 l [- 1 :2 ]= ['e' ] 591call assert_equal ([ 0 , 1 , 2 , 'e' , 3 ], l ) 592 593let l = [ 0 , 1 , 2 , 3 ] 594py 3 l = vim .bindeval ('l' ) 595py 3 l [- 10 :2 ]= ['f' ] 596call assert_equal ([ 'f' , 2 , 3 ], l ) 597 598let l = [ 0 , 1 , 2 , 3 ] 599py 3 l = vim .bindeval ('l' ) 600py 3 l [2 :- 10 ]= ['g' ] 601call assert_equal ([ 0 , 1 , 'g' , 2 , 3 ], l ) 602 603let l = [] 604py 3 l = vim .bindeval ('l' ) 605py 3 l [0 :0 ]= ['h' ] 606call assert_equal ([ 'h' ], l ) 607 608let l = range ( 8 ) 609py 3 l = vim .bindeval ('l' ) 610py 3 l [2 :6 :2 ]= [10 ,20 ] 611call assert_equal ([ 0 , 1 , 10 , 3 , 20 , 5 , 6 , 7 ], l ) 612 613let l = range ( 8 ) 614py 3 l = vim .bindeval ('l' ) 615py 3 l [6 :2 :- 2 ]= [10 ,20 ] 616call assert_equal ([ 0 , 1 , 2 , 3 , 20 , 5 , 10 , 7 ], l ) 617 618let l = range ( 8 ) 619py 3 l = vim .bindeval ('l' ) 620py 3 l [6 :2 ]= () 621call assert_equal ([ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ], l ) 622 623let l = range ( 8 ) 624py 3 l = vim .bindeval ('l' ) 625py 3 l [6 :2 :1 ]= () 626call assert_equal ([ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ], l ) 627 628let l = range ( 8 ) 629py 3 l = vim .bindeval ('l' ) 630py 3 l [2 :2 :1 ]= () 631call assert_equal ([ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ], l ) 632endfunc 633 634" Locked variables 635func Test_python3_lockedvar () 636throw 'Skipped: Nvim does not support vim.bindeval()' 637new 638py 3 cb = vim .current .buffer 639let l = [ 0 , 1 , 2 , 3 ] 640py 3 l = vim .bindeval ('l' ) 641lockvar ! l 642py 3 << trim EOF 643try : 644l [2]='i' 645except vim.error: 646cb .append('l[2] threw vim.error: ' + emsg(sys.exc_info())) 647EOF 648call assert_equal ([ '' , "l[2] threw vim.error: error:('list is locked',)" ], 649 \getline ( 1 , '$' )) 650call assert_equal ([ 0 , 1 , 2 , 3 ], l ) 651unlockvar ! l 652close ! 653endfunc 654 655" Test for calling a function 656func Test_python3_function_call () 657throw 'Skipped: Nvim does not support vim.bindeval()' 658func New (...) 659return [ 'NewStart' ] + a: 000 + [ 'NewEnd' ] 660endfunc 661 662func DictNew (...) dict 663return [ 'DictNewStart' ] + a: 000 + [ 'DictNewEnd' , self ] 664endfunc 665 666new 667let l = [ function ( 'New' ), function ( 'DictNew' )] 668py 3 l = vim .bindeval ('l' ) 669py 3 l .extend (list (l [0 ](1 ,2 ,3 ))) 670call assert_equal ([ function ( 'New' ), function ( 'DictNew' ), 'NewStart' , 1 , 2 , 3 , 'NewEnd' ], l ) 671py 3 l .extend (list (l [1 ](1 ,2 ,3 ,self = {'a' :'b' }))) 672call assert_equal ([ function ( 'New' ), function ( 'DictNew' ), 'NewStart' , 1 , 2 , 3 , 'NewEnd' , 'DictNewStart' , 1 , 2 , 3 , 'DictNewEnd' , { 'a' : 'b' }], l ) 673py 3 l += [[l [0 ].name ]] 674call assert_equal ([ function ( 'New' ), function ( 'DictNew' ), 'NewStart' , 1 , 2 , 3 , 'NewEnd' , 'DictNewStart' , 1 , 2 , 3 , 'DictNewEnd' , { 'a' : 'b' }, [ 'New' ]], l ) 675py 3 ee ('l[1](1, 2, 3)' ) 676call assert_equal ( "l[1](1, 2, 3):(<class 'vim.error'>, error('Vim:E725: Calling dict function without Dictionary: DictNew',))" , getline ( 2 )) 677 %d 678py 3 f = l [0 ] 679delfunction New 680py 3 ee ('f(1, 2, 3)' ) 681call assert_equal ( "f(1, 2, 3):(<class 'vim.error'>, error('Vim:E117: Unknown function: New',))" , getline ( 2 )) 682close ! 683delfunction DictNew 684endfunc 685 686func Test_python3_float () 687throw 'Skipped: Nvim does not support vim.bindeval()' 688CheckFeature float 689let l = [ 0.0 ] 690py 3 l = vim .bindeval ('l' ) 691py 3 l .extend ([0.0 ]) 692call assert_equal ([ 0.0 , 0.0 ], l ) 693endfunc 694 695" Test for Dict key errors 696func Test_python3_dict_key_error () 697throw 'Skipped: Nvim does not support vim.bindeval()' 698let messages = [] 699py 3 << trim EOF 700import sys 701d = vim.bindeval('{}') 702m = vim.bindeval('messages') 703def em(expr, g=globals(), l=locals()): 704try : 705exec ( expr , g, l) 706except Exception as e: 707if sys . version_info >= ( 3 , 5) and e.__class__ isValueError and str(e) == 'embedded null byte': 708m .extend([TypeError.__name__]) 709else : 710m .extend([e.__class__.__name__]) 711 712em ('d["abc1"]') 713em ('d["abc1"]="\\0"') 714em ('d["abc1"]=vim') 715em ('d[""]=1') 716em ('d["a\\0b"]=1') 717em ('d[b"a\\0b"]=1') 718em ('d.pop("abc1")') 719em ('d.popitem()') 720del em 721del m 722EOF 723 724call assert_equal ([ 'KeyError' , 'TypeError' , 'TypeError' , 'ValueError' , 725 \'TypeError' , 'TypeError' , 'KeyError' , 'KeyError' ], messages ) 726unlet messages 727endfunc 728 729" Test for locked and scope attributes 730func Test_python3_lock_scope_attr () 731throw 'Skipped: Nvim does not support vim.bindeval()' 732let d = {} |let dl = {} |lockvar dl 733let res = [] 734for s in split ( "d dl v: g:" ) 735let name = tr ( s , ':' , 's' ) 736execute 'py3 ' .. name .. ' = vim.bindeval("' .. s .. '")' 737call add ( res , s .. ' : ' .. join ( map ([ 'locked' , 'scope' ], 738 \'v:val .. ":" .. py3eval(name .. "." .. v:val)' ), ';' )) 739endfor 740call assert_equal ([ 'd : locked:0;scope:0' , 'dl : locked:1;scope:0' , 741 \'v: : locked:2;scope:1' , 'g: : locked:0;scope:2' ], res ) 742 743silent ! let d . abc2 = 1 744silent ! let dl . abc3 = 1 745py 3 d .locked = True 746py 3 dl .locked = False 747silent ! let d . def = 1 748silent ! let dl . def = 1 749call assert_equal ({ 'abc2' : 1 }, d ) 750call assert_equal ({ 'def' : 1 }, dl ) 751unlet d dl 752 753let l = [] |let ll = [] |lockvar ll 754let res = [] 755for s in split ( "l ll" ) 756let name = tr ( s , ':' , 's' ) 757execute 'py3 ' .. name .. '=vim.bindeval("' .. s .. '")' 758call add ( res , s .. ' : locked:' .. py3eval ( name .. '.locked' )) 759endfor 760call assert_equal ([ 'l : locked:0' , 'll : locked:1' ], res ) 761 762silent ! call extend ( l , [ 0 ]) 763silent ! call extend ( ll , [ 0 ]) 764py 3 l .locked = True 765py 3 ll .locked = False 766silent ! call extend ( l , [ 1 ]) 767silent ! call extend ( ll , [ 1 ]) 768call assert_equal ([ 0 ], l ) 769call assert_equal ([ 1 ], ll ) 770unlet l ll 771endfunc 772 773" Test for py3eval() 774func Test_python3_pyeval () 775let l = py3eval ( '[0, 1, 2]' ) 776call assert_equal ([ 0 , 1 , 2 ], l ) 777 778let d = py3eval ( '{"a": "b", "c": 1, "d": ["e"]}' ) 779call assert_equal ([[ 'a' , 'b' ], [ 'c' , 1 ], [ 'd' , [ 'e' ]]], sort ( items ( d ))) 780 781let v: errmsg = '' 782" call assert_equal(v:none, py3eval('None')) 783call assert_equal ( '' , v: errmsg ) 784 785if has ( 'float' ) 786call assert_equal ( 0 , py3eval ( '0.0' )) 787endif 788 789" Invalid values: 790" let caught_859 = 0 791" try 792" let v = py3eval('"\0"') 793" catch /E859:/ 794" let caught_859 = 1 795" endtry 796" call assert_equal(1, caught_859) 797 798" let caught_859 = 0 799" try 800" let v = py3eval('{"\0" : 1}') 801" catch /E859:/ 802" let caught_859 = 1 803" endtry 804" call assert_equal(1, caught_859) 805 806let caught_nameerr = 0 807try 808let v = py3eval ( "undefined_name" ) 809catch /NameError: name 'undefined_name'/ 810let caught_nameerr = 1 811endtry 812call assert_equal ( 1 , caught_nameerr ) 813 814let caught_859 = 0 815try 816let v = py3eval ( "vim" ) 817catch /can not serialize 'LegacyVim' object/ 818let caught_859 = 1 819endtry 820call assert_equal ( 1 , caught_859 ) 821endfunc 822 823" threading 824" Running py3do command (Test_pydo) before this test, stops the python thread 825" from running. So this test should be run before the pydo test 826func Test_aaa_python_threading () 827throw 'Skipped: Nvim does not support vim.bindeval()' 828let l = [ 0 ] 829py 3 l = vim .bindeval ('l' ) 830py 3 << trim EOF 831import threading 832import time 833 834class T(threading.Thread): 835def __init__(self): 836threading .Thread.__init__(self) 837self .t = 0 838self .running = True 839 840def run(self): 841while self . running : 842self .t += 1 843time .sleep(0.1) 844 845t = T() 846del T 847t .start() 848EOF 849 850sleep 1 851py 3 t .running = False 852py 3 t .join () 853 854" Check if the background thread is working. Count should be 10, but on a 855" busy system (AppVeyor) it can be much lower. 856py 3 l [0 ]= t .t > 4 857py 3 del time 858py 3 del threading 859py 3 del t 860call assert_equal ([ 1 ], l ) 861endfunc 862 863" settrace 864func Test_python3_settrace () 865throw 'Skipped: Nvim does not support vim.bindeval()' 866let l = [] 867py 3 l = vim .bindeval ('l' ) 868py 3 << trim EOF 869import sys 870 871def traceit(frame, event, arg): 872global l 873if event == "line" : 874l += [frame.f_lineno] 875return traceit 876 877def trace_main(): 878for i in range ( 5 ): 879pass 880EOF 881py 3 sys .settrace (traceit ) 882py 3 trace_main () 883py 3 sys .settrace (None ) 884py 3 del traceit 885py 3 del trace_main 886call assert_equal ([ 1 , 10 , 11 , 10 , 11 , 10 , 11 , 10 , 11 , 10 , 11 , 10 , 1 ], l ) 887endfunc 888 889" Slice 890func Test_python3_list_slice () 891throw 'Skipped: Nvim does not support vim.bindeval()' 892py 3 ll = vim .bindeval ('[0, 1, 2, 3, 4, 5]' ) 893py 3 l = ll [:4 ] 894call assert_equal ([ 0 , 1 , 2 , 3 ], py3eval ( 'l' )) 895py 3 l = ll [2 :] 896call assert_equal ([ 2 , 3 , 4 , 5 ], py3eval ( 'l' )) 897py 3 l = ll [:- 4 ] 898call assert_equal ([ 0 , 1 ], py3eval ( 'l' )) 899py 3 l = ll [- 2 :] 900call assert_equal ([ 4 , 5 ], py3eval ( 'l' )) 901py 3 l = ll [2 :4 ] 902call assert_equal ([ 2 , 3 ], py3eval ( 'l' )) 903py 3 l = ll [4 :2 ] 904call assert_equal ([], py3eval ( 'l' )) 905py 3 l = ll [- 4 :- 2 ] 906call assert_equal ([ 2 , 3 ], py3eval ( 'l' )) 907py 3 l = ll [- 2 :- 4 ] 908call assert_equal ([], py3eval ( 'l' )) 909py 3 l = ll [:] 910call assert_equal ([ 0 , 1 , 2 , 3 , 4 , 5 ], py3eval ( 'l' )) 911py 3 l = ll [0 :6 ] 912call assert_equal ([ 0 , 1 , 2 , 3 , 4 , 5 ], py3eval ( 'l' )) 913py 3 l = ll [- 10 :10 ] 914call assert_equal ([ 0 , 1 , 2 , 3 , 4 , 5 ], py3eval ( 'l' )) 915py 3 l = ll [4 :2 :- 1 ] 916call assert_equal ([ 4 , 3 ], py3eval ( 'l' )) 917py 3 l = ll [::2 ] 918call assert_equal ([ 0 , 2 , 4 ], py3eval ( 'l' )) 919py 3 l = ll [4 :2 :1 ] 920call assert_equal ([], py3eval ( 'l' )) 921py 3 del l 922endfunc 923 924" Vars 925func Test_python3_vars () 926let g: foo = 'bac' 927let w: abc3 = 'def' 928let b: baz = 'bar' 929let t: bar = 'jkl' 930try 931throw "Abc" 932catch /Abc/ 933call assert_equal ( 'Abc' , py3eval ( 'vim.vvars[''exception'']' )) 934endtry 935call assert_equal ( 'bac' , py3eval ( 'vim.vars[''foo'']' )) 936call assert_equal ( 'def' , py3eval ( 'vim.current.window.vars[''abc3'']' )) 937call assert_equal ( 'bar' , py3eval ( 'vim.current.buffer.vars[''baz'']' )) 938call assert_equal ( 'jkl' , py3eval ( 'vim.current.tabpage.vars[''bar'']' )) 939endfunc 940 941" Options 942" paste: boolean, global 943" previewheight number, global 944" operatorfunc: string, global 945" number: boolean, window-local 946" numberwidth: number, window-local 947" colorcolumn: string, window-local 948" statusline: string, window-local/global 949" autoindent: boolean, buffer-local 950" shiftwidth: number, buffer-local 951" omnifunc: string, buffer-local 952" preserveindent: boolean, buffer-local/global 953" path: string, buffer-local/global 954func Test_python3_opts () 955throw 'Skipped: Nvim does not support vim.bindeval()' 956let g: res = [] 957let g: bufs = [ bufnr ( '%' )] 958new 959let g: bufs += [ bufnr ( '%' )] 960vnew 961let g: bufs += [ bufnr ( '%' )] 962wincmd j 963vnew 964let g: bufs += [ bufnr ( '%' )] 965wincmd l 966 967func RecVars ( opt ) 968let gval = string ( eval ( '&g:' .. a: opt )) 969let wvals = join ( map ( range ( 1 , 4 ), 970 \'v:val .. ":" .. string(getwinvar(v:val, "&" .. a:opt))' )) 971let bvals = join ( map ( copy ( g: bufs ), 972 \'v:val .. ":" .. string(getbufvar(v:val, "&" .. a:opt))' )) 973call add ( g: res , ' G: ' .. gval ) 974call add ( g: res , ' W: ' .. wvals ) 975call add ( g: res , ' B: ' .. wvals ) 976endfunc 977 978py 3 << trim EOF 979def e(s, g=globals(), l=locals()): 980try : 981exec ( s , g, l) 982except Exception as e: 983vim .command('return ' + repr(e.__class__.__name__)) 984 985def ev(s, g=globals(), l=locals()): 986try : 987return eval ( s , g , l ) 988except Exception as e: 989vim .command('let exc=' + repr(e.__class__.__name__)) 990return 0 991EOF 992 993func E ( s ) 994python 3 e (vim .eval ('a:s' )) 995endfunc 996 997func Ev ( s ) 998let r = py3eval ( 'ev(vim.eval("a:s"))' ) 999if exists ( 'exc' ) 1000throw exc 1001endif 1002return r 1003endfunc 1004 1005py 3 gopts1 = vim .options 1006py 3 wopts1 = vim .windows [2 ].options 1007py 3 wopts2 = vim .windows [0 ].options 1008py 3 wopts3 = vim .windows [1 ].options 1009py 3 bopts1 = vim .buffers [vim .bindeval ("g:bufs" )[2 ]].options 1010py 3 bopts2 = vim .buffers [vim .bindeval ("g:bufs" )[1 ]].options 1011py 3 bopts3 = vim .buffers [vim .bindeval ("g:bufs" )[0 ]].options 1012call add ( g: res , 'wopts iters equal: ' .. 1013 \py3eval ( 'list(wopts1) == list(wopts2)' )) 1014call add ( g: res , 'bopts iters equal: ' .. 1015 \py3eval ( 'list(bopts1) == list(bopts2)' )) 1016py 3 gset = set (iter (gopts1 )) 1017py 3 wset = set (iter (wopts1 )) 1018py 3 bset = set (iter (bopts1 )) 1019 1020set path = .,..,, 1021let lst = [] 1022let lst += [[ 'paste' , 1 , 0 , 1 , 2 , 1 , 1 , 0 ]] 1023let lst += [[ 'previewheight' , 5 , 1 , 6 , 'a' , 0 , 1 , 0 ]] 1024let lst += [[ 'operatorfunc' , 'A' , 'B' , 'C' , 2 , 0 , 1 , 0 ]] 1025let lst += [[ 'number' , 0 , 1 , 1 , 0 , 1 , 0 , 1 ]] 1026let lst += [[ 'numberwidth' , 2 , 3 , 5 , -100 , 0 , 0 , 1 ]] 1027let lst += [[ 'colorcolumn' , '+1' , '+2' , '+3' , 'abc4' , 0 , 0 , 1 ]] 1028let lst += [[ 'statusline' , '1' , '2' , '4' , 0 , 0 , 1 , 1 ]] 1029let lst += [[ 'autoindent' , 0 , 1 , 1 , 2 , 1 , 0 , 2 ]] 1030let lst += [[ 'shiftwidth' , 0 , 2 , 1 , 3 , 0 , 0 , 2 ]] 1031let lst += [[ 'omnifunc' , 'A' , 'B' , 'C' , 1 , 0 , 0 , 2 ]] 1032let lst += [[ 'preserveindent' , 0 , 1 , 1 , 2 , 1 , 1 , 2 ]] 1033let lst += [[ 'path' , '.,,' , ',,' , '.' , 0 , 0 , 1 , 2 ]] 1034for [ oname , oval1 , oval2 , oval3 , invval , bool , global , local ] in lst 1035py 3 oname = vim .eval ('oname' ) 1036py 3 oval1 = vim .bindeval ('oval1' ) 1037py 3 oval2 = vim .bindeval ('oval2' ) 1038py 3 oval3 = vim .bindeval ('oval3' ) 1039if invval is 0 || invval is 1 1040py 3 invval = bool (vim .bindeval ('invval' )) 1041else 1042py 3 invval = vim .bindeval ('invval' ) 1043endif 1044if bool 1045py 3 oval1 = bool (oval1 ) 1046py 3 oval2 = bool (oval2 ) 1047py 3 oval3 = bool (oval3 ) 1048endif 1049call add ( g: res , '>>> ' .. oname ) 1050call add ( g: res , ' g/w/b:' .. py3eval ( 'oname in gset' ) .. '/' .. 1051 \py3eval ( 'oname in wset' ) .. '/' .. py3eval ( 'oname in bset' )) 1052call add ( g: res , ' g/w/b (in):' .. py3eval ( 'oname in gopts1' ) .. '/' .. 1053 \py3eval ( 'oname in wopts1' ) .. '/' .. py3eval ( 'oname in bopts1' )) 1054for v in [ 'gopts1' , 'wopts1' , 'bopts1' ] 1055try 1056call add ( g: res , ' p/' .. v .. ': ' .. Ev ( 'repr(' .. v .. '[''' .. oname .. '''])' )) 1057catch 1058call add ( g: res , ' p/' .. v .. '! ' .. v: exception ) 1059endtry 1060let r = E ( v .. '[''' .. oname .. ''']=invval' ) 1061if r isnot 0 1062call add ( g: res , ' inv: ' .. string ( invval ) .. '! ' .. r ) 1063endif 1064for vv in ( v is# 'gopts1' ? [ v ] : [ v , v [: -2 ] .. '2' , v [: -2 ] .. '3' ]) 1065let val = substitute ( vv , '^.opts' , 'oval' , '' ) 1066let r = E ( vv .. '[''' .. oname .. ''']=' .. val ) 1067if r isnot 0 1068call add ( g: res , ' ' .. vv .. '! ' .. r ) 1069endif 1070endfor 1071endfor 1072call RecVars ( oname ) 1073for v in [ 'wopts3' , 'bopts3' ] 1074let r = E ( 'del ' .. v .. '["' .. oname .. '"]' ) 1075if r isnot 0 1076call add ( g: res , ' del ' .. v .. '! ' .. r ) 1077endif 1078endfor 1079call RecVars ( oname ) 1080endfor 1081delfunction RecVars 1082delfunction E 1083delfunction Ev 1084py 3 del ev 1085py 3 del e 1086only 1087for buf in g: bufs [ 1 :] 1088execute 'bwipeout!' buf 1089endfor 1090py 3 del gopts1 1091py 3 del wopts1 1092py 3 del wopts2 1093py 3 del wopts3 1094py 3 del bopts1 1095py 3 del bopts2 1096py 3 del bopts3 1097py 3 del oval1 1098py 3 del oval2 1099py 3 del oval3 1100py 3 del oname 1101py 3 del invval 1102 1103let expected =<< trim END 1104wopts iters equal: 1 1105bopts iters equal: 1 1106>>> paste 1107g/w/b:1/0/0 1108g/w/b (in):1/0/0 1109p/gopts1: False 1110p/wopts1! KeyError 1111inv: 2! KeyError 1112wopts1! KeyError 1113wopts2! KeyError 1114wopts3! KeyError 1115p/bopts1! KeyError 1116inv: 2! KeyError 1117bopts1! KeyError 1118bopts2! KeyError 1119bopts3! KeyError 1120G: 1 1121W: 1:1 2:1 3:1 4:1 1122B: 1:1 2:1 3:1 4:1 1123del wopts3! KeyError 1124del bopts3! KeyError 1125G: 1 1126W: 1:1 2:1 3:1 4:1 1127B: 1:1 2:1 3:1 4:1 1128>>> previewheight 1129g/w/b:1/0/0 1130g/w/b (in):1/0/0 1131p/gopts1: 12 1132inv: 'a'! TypeError 1133p/wopts1! KeyError 1134inv: 'a'! KeyError 1135wopts1! KeyError 1136wopts2! KeyError 1137wopts3! KeyError 1138p/bopts1! KeyError 1139inv: 'a'! KeyError 1140bopts1! KeyError 1141bopts2! KeyError 1142bopts3! KeyError 1143G: 5 1144W: 1:5 2:5 3:5 4:5 1145B: 1:5 2:5 3:5 4:5 1146del wopts3! KeyError 1147del bopts3! KeyError 1148G: 5 1149W: 1:5 2:5 3:5 4:5 1150B: 1:5 2:5 3:5 4:5 1151>>> operatorfunc 1152g/w/b:1/0/0 1153g/w/b (in):1/0/0 1154p/gopts1: b'' 1155inv: 2! TypeError 1156p/wopts1! KeyError 1157inv: 2! KeyError 1158wopts1! KeyError 1159wopts2! KeyError 1160wopts3! KeyError 1161p/bopts1! KeyError 1162inv: 2! KeyError 1163bopts1! KeyError 1164bopts2! KeyError 1165bopts3! KeyError 1166G: 'A' 1167W: 1:'A' 2:'A' 3:'A' 4:'A' 1168B: 1:'A' 2:'A' 3:'A' 4:'A' 1169del wopts3! KeyError 1170del bopts3! KeyError 1171G: 'A' 1172W: 1:'A' 2:'A' 3:'A' 4:'A' 1173B: 1:'A' 2:'A' 3:'A' 4:'A' 1174>>> number 1175g/w/b:0/1/0 1176g/w/b (in):0/1/0 1177p/gopts1! KeyError 1178inv: 0! KeyError 1179gopts1! KeyError 1180p/wopts1: False 1181p/bopts1! KeyError 1182inv: 0! KeyError 1183bopts1! KeyError 1184bopts2! KeyError 1185bopts3! KeyError 1186G: 0 1187W: 1:1 2:1 3:0 4:0 1188B: 1:1 2:1 3:0 4:0 1189del wopts3! ValueError 1190del bopts3! KeyError 1191G: 0 1192W: 1:1 2:1 3:0 4:0 1193B: 1:1 2:1 3:0 4:0 1194>>> numberwidth 1195g/w/b:0/1/0 1196g/w/b (in):0/1/0 1197p/gopts1! KeyError 1198inv: -100! KeyError 1199gopts1! KeyError 1200p/wopts1: 4 1201inv: -100! error 1202p/bopts1! KeyError 1203inv: -100! KeyError 1204bopts1! KeyError 1205bopts2! KeyError 1206bopts3! KeyError 1207G: 4 1208W: 1:3 2:5 3:2 4:4 1209B: 1:3 2:5 3:2 4:4 1210del wopts3! ValueError 1211del bopts3! KeyError 1212G: 4 1213W: 1:3 2:5 3:2 4:4 1214B: 1:3 2:5 3:2 4:4 1215>>> colorcolumn 1216g/w/b:0/1/0 1217g/w/b (in):0/1/0 1218p/gopts1! KeyError 1219inv: 'abc4'! KeyError 1220gopts1! KeyError 1221p/wopts1: b'' 1222inv: 'abc4'! error 1223p/bopts1! KeyError 1224inv: 'abc4'! KeyError 1225bopts1! KeyError 1226bopts2! KeyError 1227bopts3! KeyError 1228G: '' 1229W: 1:'+2' 2:'+3' 3:'+1' 4:'' 1230B: 1:'+2' 2:'+3' 3:'+1' 4:'' 1231del wopts3! ValueError 1232del bopts3! KeyError 1233G: '' 1234W: 1:'+2' 2:'+3' 3:'+1' 4:'' 1235B: 1:'+2' 2:'+3' 3:'+1' 4:'' 1236>>> statusline 1237g/w/b:1/1/0 1238g/w/b (in):1/1/0 1239p/gopts1: b'' 1240inv: 0! TypeError 1241p/wopts1: None 1242inv: 0! TypeError 1243p/bopts1! KeyError 1244inv: 0! KeyError 1245bopts1! KeyError 1246bopts2! KeyError 1247bopts3! KeyError 1248G: '1' 1249W: 1:'2' 2:'4' 3:'1' 4:'1' 1250B: 1:'2' 2:'4' 3:'1' 4:'1' 1251del bopts3! KeyError 1252G: '1' 1253W: 1:'2' 2:'1' 3:'1' 4:'1' 1254B: 1:'2' 2:'1' 3:'1' 4:'1' 1255>>> autoindent 1256g/w/b:0/0/1 1257g/w/b (in):0/0/1 1258p/gopts1! KeyError 1259inv: 2! KeyError 1260gopts1! KeyError 1261p/wopts1! KeyError 1262inv: 2! KeyError 1263wopts1! KeyError 1264wopts2! KeyError 1265wopts3! KeyError 1266p/bopts1: False 1267G: 0 1268W: 1:0 2:1 3:0 4:1 1269B: 1:0 2:1 3:0 4:1 1270del wopts3! KeyError 1271del bopts3! ValueError 1272G: 0 1273W: 1:0 2:1 3:0 4:1 1274B: 1:0 2:1 3:0 4:1 1275>>> shiftwidth 1276g/w/b:0/0/1 1277g/w/b (in):0/0/1 1278p/gopts1! KeyError 1279inv: 3! KeyError 1280gopts1! KeyError 1281p/wopts1! KeyError 1282inv: 3! KeyError 1283wopts1! KeyError 1284wopts2! KeyError 1285wopts3! KeyError 1286p/bopts1: 8 1287G: 8 1288W: 1:0 2:2 3:8 4:1 1289B: 1:0 2:2 3:8 4:1 1290del wopts3! KeyError 1291del bopts3! ValueError 1292G: 8 1293W: 1:0 2:2 3:8 4:1 1294B: 1:0 2:2 3:8 4:1 1295>>> omnifunc 1296g/w/b:0/0/1 1297g/w/b (in):0/0/1 1298p/gopts1! KeyError 1299inv: 1! KeyError 1300gopts1! KeyError 1301p/wopts1! KeyError 1302inv: 1! KeyError 1303wopts1! KeyError 1304wopts2! KeyError 1305wopts3! KeyError 1306p/bopts1: b'' 1307inv: 1! TypeError 1308G: '' 1309W: 1:'A' 2:'B' 3:'' 4:'C' 1310B: 1:'A' 2:'B' 3:'' 4:'C' 1311del wopts3! KeyError 1312del bopts3! ValueError 1313G: '' 1314W: 1:'A' 2:'B' 3:'' 4:'C' 1315B: 1:'A' 2:'B' 3:'' 4:'C' 1316>>> preserveindent 1317g/w/b:0/0/1 1318g/w/b (in):0/0/1 1319p/gopts1! KeyError 1320inv: 2! KeyError 1321gopts1! KeyError 1322p/wopts1! KeyError 1323inv: 2! KeyError 1324wopts1! KeyError 1325wopts2! KeyError 1326wopts3! KeyError 1327p/bopts1: False 1328G: 0 1329W: 1:0 2:1 3:0 4:1 1330B: 1:0 2:1 3:0 4:1 1331del wopts3! KeyError 1332del bopts3! ValueError 1333G: 0 1334W: 1:0 2:1 3:0 4:1 1335B: 1:0 2:1 3:0 4:1 1336>>> path 1337g/w/b:1/0/1 1338g/w/b (in):1/0/1 1339p/gopts1: b'.,..,,' 1340inv: 0! TypeError 1341p/wopts1! KeyError 1342inv: 0! KeyError 1343wopts1! KeyError 1344wopts2! KeyError 1345wopts3! KeyError 1346p/bopts1: None 1347inv: 0! TypeError 1348G: '.,,' 1349W: 1:'.,,' 2:',,' 3:'.,,' 4:'.' 1350B: 1:'.,,' 2:',,' 3:'.,,' 4:'.' 1351del wopts3! KeyError 1352G: '.,,' 1353W: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,' 1354B: 1:'.,,' 2:',,' 3:'.,,' 4:'.,,' 1355END 1356 1357call assert_equal ( expected , g: res ) 1358unlet g: res 1359endfunc 1360 1361" Test for vim.buffer object 1362func Test_python3_buffer () 1363throw 'Skipped: TODO: ' 1364new 1365call setline ( 1 , "Hello\nWorld" ) 1366call assert_fails ( "let x = py3eval('vim.current.buffer[0]')" , 'E859:' ) 1367 %bw ! 1368 1369edit Xfile1 1370let bnr1 = bufnr () 1371py 3 cb = vim .current .buffer 1372vnew Xfile2 1373let bnr2 = bufnr () 1374call setline ( 1 , [ 'First line' , 'Second line' , 'Third line' ]) 1375py 3 b = vim .current .buffer 1376wincmd w 1377 1378" Tests BufferAppend and BufferItem 1379py 3 cb .append (b [0 ]) 1380call assert_equal ([ 'First line' ], getbufline ( bnr1 , 2 )) 1381 %d 1382 1383" Tests BufferSlice and BufferAssSlice 1384py 3 cb .append ('abc5' )# Will be overwritten 1385py 3 cb [- 1 :]= b [:- 2 ] 1386call assert_equal ([ 'First line' ], getbufline ( bnr1 , 2 )) 1387 %d 1388 1389" Test BufferLength and BufferAssSlice 1390py 3 cb .append ('def' )# Will not be overwritten 1391py 3 cb [len (cb ):]= b [:] 1392call assert_equal ([ 'def' , 'First line' , 'Second line' , 'Third line' ], 1393 \getbufline ( bnr1 , 2 , '$' )) 1394 %d 1395 1396" Test BufferAssItem and BufferMark 1397call setbufline ( bnr1 , 1 , [ 'one' , 'two' , 'three' ]) 1398call cursor ( 1 , 3 ) 1399normal ma 1400py 3 cb .append ('ghi' )# Will be overwritten 1401py 3 cb [- 1 ]= repr ((len (cb )- cb .mark ('a' )[0 ],cb .mark ('a' )[1 ])) 1402call assert_equal ([ '(3, 2)' ], getbufline ( bnr1 , 4 )) 1403 %d 1404 1405" Test BufferRepr 1406py 3 cb .append (repr (cb )+ repr (b )) 1407call assert_equal ([ '<buffer Xfile1><buffer Xfile2>' ], getbufline ( bnr1 , 2 )) 1408 %d 1409 1410" Modify foreign buffer 1411py 3 << trim EOF 1412b .append('foo') 1413b [0]='bar' 1414b [0:0]=['baz'] 1415vim .command('call append("$", getbufline(%i, 1,"$" ))' % b.number) 1416EOF 1417call assert_equal ([ 'baz' , 'bar' , 'Second line' , 'Third line' , 'foo' ], 1418 \getbufline ( bnr2 , 1 , '$' )) 1419 %d 1420 1421" Test assigning to name property 1422augroup BUFS 1423autocmd BufFilePost * python 3 cb .append (vim .eval ('expand("<abuf>")' )+ ':BufFilePost:' + vim .eval ('bufnr("%")' )) 1424autocmd BufFilePre * python 3 cb .append (vim .eval ('expand("<abuf>")' )+ ':BufFilePre:' + vim .eval ('bufnr("%")' )) 1425augroup END 1426py 3 << trim EOF 1427import os 1428old _name = cb.name 1429cb .name ='foo' 1430cb .append(cb.name[-11:].replace(os.path.sep,'/' )) 1431b .name ='bar' 1432cb .append(b.name[-11:].replace(os.path.sep,'/' )) 1433cb .name = old_name 1434cb .append(cb.name[-14:].replace(os.path.sep,'/' )) 1435del old_name 1436EOF 1437call assert_equal ([ bnr1 .. ':BufFilePre:' .. bnr1 , 1438 \bnr1 .. ':BufFilePost:' .. bnr1 , 1439 \'testdir/foo' , 1440 \bnr2 .. ':BufFilePre:' .. bnr2 , 1441 \bnr2 .. ':BufFilePost:' .. bnr2 , 1442 \'testdir/bar' , 1443 \bnr1 .. ':BufFilePre:' .. bnr1 , 1444 \bnr1 .. ':BufFilePost:' .. bnr1 , 1445 \'testdir/Xfile1' ], getbufline ( bnr1 , 2 , '$' )) 1446 %d 1447 1448" Test CheckBuffer 1449py 3 << trim EOF 1450for _b in vim . buffers : 1451if _b is not cb: 1452vim .command('bwipeout! ' + str(_b.number)) 1453del _b 1454cb .append('valid: b:%s, cb:%s' % (repr(b.valid), repr(cb.valid))) 1455EOF 1456call assert_equal ( 'valid: b:False, cb:True' , getline ( 2 )) 1457 %d 1458 1459py 3 << trim EOF 1460for expr in ( 'b[1]' , 'b[:] = ["A", "B"]','b[:]','b.append("abc6")'): 1461try : 1462exec ( expr ) 1463except vim.error: 1464pass 1465else : 1466 #Usually aSEGV here 1467 #Should not happen in any case 1468cb .append('No exception for ' + expr) 1469vim .command('cd .') 1470del b 1471EOF 1472call assert_equal ([ '' ], getline ( 1 , '$' )) 1473 1474augroup BUFS 1475autocmd ! 1476augroup END 1477augroup ! BUFS 1478 %bw ! 1479endfunc 1480 1481" Test vim.buffers object 1482func Test_python3_buffers () 1483throw 'Skipped: TODO: ' 1484 %bw ! 1485edit Xfile 1486py 3 cb = vim .current .buffer 1487set hidden 1488edit a 1489buffer # 1490edit b 1491buffer # 1492edit c 1493buffer # 1494py 3 << trim EOF 1495 #Check GCing iterator that was not fully exhausted 1496i = iter(vim.buffers) 1497cb .append('i:' + str(next(i))) 1498 # and also check creating more than one iterator at a time 1499i 2 = iter(vim.buffers) 1500cb .append('i2:' + str(next(i2))) 1501cb .append('i:' + str(next(i))) 1502 #The following should triggerGC and not cause any problems 1503del i 1504del i2 1505i 3 = iter(vim.buffers) 1506cb .append('i3:' + str(next(i3))) 1507del i3 1508EOF 1509call assert_equal ([ 'i:<buffer Xfile>' , 1510 \'i2:<buffer Xfile>' , 'i:<buffer a>' , 'i3:<buffer Xfile>' ], 1511 \getline ( 2 , '$' )) 1512 %d 1513 1514py 3 << trim EOF 1515prevnum = 0 1516for b in vim . buffers : 1517 #Check buffer order 1518if prevnum >= b . number : 1519cb .append('!!! Buffer numbers not in strictly ascending order') 1520 #Check indexing: vim.buffers[number].number == number 1521cb .append(str(b.number) +':' + repr(vim.buffers[b.number]) + \ 1522 '=' + repr(b)) 1523prevnum = b.number 1524del prevnum 1525 1526cb .append(str(len(vim.buffers))) 1527EOF 1528call assert_equal ([ bufnr ( 'Xfile' ) .. ':<buffer Xfile>=<buffer Xfile>' , 1529 \bufnr ( 'a' ) .. ':<buffer a>=<buffer a>' , 1530 \bufnr ( 'b' ) .. ':<buffer b>=<buffer b>' , 1531 \bufnr ( 'c' ) .. ':<buffer c>=<buffer c>' , '4' ], getline ( 2 , '$' )) 1532 %d 1533 1534py 3 << trim EOF 1535bnums = list(map(lambda b: b.number, vim.buffers))[1:] 1536 1537 #Test wiping out buffer with existing iterator 1538i 4 = iter(vim.buffers) 1539cb .append('i4:' + str(next(i4))) 1540vim .command('bwipeout! ' + str(bnums.pop(0))) 1541try : 1542next (i4) 1543except vim.error: 1544pass 1545else : 1546cb .append('!!!! No vim.error') 1547i 4 = iter(vim.buffers) 1548vim .command('bwipeout! ' + str(bnums.pop(-1))) 1549vim .command('bwipeout! ' + str(bnums.pop(-1))) 1550cb .append('i4:' + str(next(i4))) 1551try : 1552next (i4) 1553except StopIteration: 1554cb .append('StopIteration') 1555del i4 1556del bnums 1557EOF 1558call assert_equal ([ 'i4:<buffer Xfile>' , 1559 \'i4:<buffer Xfile>' , 'StopIteration' ], getline ( 2 , '$' )) 1560 %bw ! 1561endfunc 1562 1563" Test vim.{tabpage,window}list and vim.{tabpage,window} objects 1564func Test_python3_tabpage_window () 1565throw 'Skipped: TODO: ' 1566 %bw 1567edit Xfile 1568py 3 cb = vim .current .buffer 1569tabnew 0 1570tabnew 1 1571vnew a.1 1572tabnew 2 1573vnew a.2 1574vnew b.2 1575vnew c.2 1576 1577py 3 << trim EOF 1578cb .append('Number of tabs: ' + str(len(vim.tabpages))) 1579cb .append('Current tab pages:') 1580def W(w): 1581if '(unknown)' in repr(w): 1582return '<window object (unknown)>' 1583else : 1584return repr ( w ) 1585 1586def Cursor(w, start=len(cb)): 1587if w . buffer is cb : 1588return repr (( start - w . cursor [ 0 ], w . cursor [ 1 ])) 1589else : 1590return repr ( w . cursor ) 1591 1592for t in vim . tabpages : 1593cb .append('' + repr(t) + ' (' + str(t.number) +')' +': ' + \ 1594str (len(t.windows)) +' windows, current is ' + W(t.window)) 1595cb .append(' Windows:') 1596for w in t . windows : 1597cb .append('' + W(w) + ' (' + str(w.number) +')' + \ 1598 ':displays buffer ' + repr(w.buffer) + \ 1599 ';cursor is at ' + Cursor(w)) 1600 #Other values depend on the size of the terminal, so they are checked 1601 # partly: 1602for attr in ( 'height' , 'row', 'width', 'col'): 1603try : 1604aval = getattr(w, attr) 1605if type ( aval ) is not int: 1606raise TypeError 1607if aval < 0 : 1608raise ValueError 1609except Exception as e: 1610cb .append('!!!!!! Error while getting attribute ' + attr + \ 1611 ': ' + e.__class__.__name__) 1612del aval 1613del attr 1614w .cursor = (len(w.buffer), 0) 1615del W 1616del Cursor 1617cb .append('Number of windows in current tab page: ' + \ 1618str (len(vim.windows))) 1619if list ( vim . windows ) != list ( vim . current . tabpage . windows ): 1620cb .append('!!!!!! Windows differ') 1621EOF 1622 1623let expected =<< trim END 1624Number of tabs: 4 1625Current tab pages: 1626<tabpage 0>(1): 1 windows, current is <window object (unknown)> 1627Windows: 1628<window object (unknown)>(1): displays buffer <buffer Xfile>; cursor is at (2, 0) 1629<tabpage 1>(2): 1 windows, current is <window object (unknown)> 1630Windows: 1631<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0) 1632<tabpage 2>(3): 2 windows, current is <window object (unknown)> 1633Windows: 1634<window object (unknown)>(1): displays buffer <buffer a.1>; cursor is at (1, 0) 1635<window object (unknown)>(2): displays buffer <buffer 1>; cursor is at (1, 0) 1636<tabpage 3>(4): 4 windows, current is <window 0> 1637Windows: 1638<window 0>(1): displays buffer <buffer c.2>; cursor is at (1, 0) 1639<window 1>(2): displays buffer <buffer b.2>; cursor is at (1, 0) 1640<window 2>(3): displays buffer <buffer a.2>; cursor is at (1, 0) 1641<window 3>(4): displays buffer <buffer 2>; cursor is at (1, 0) 1642Number of windows in current tab page: 4 1643END 1644call assert_equal ( expected , getbufline ( bufnr ( 'Xfile' ), 2 , '$' )) 1645 %bw ! 1646endfunc 1647 1648" Test vim.current 1649func Test_python3_vim_current () 1650throw 'Skipped: TODO: ' 1651 %bw 1652edit Xfile 1653py 3 cb = vim .current .buffer 1654tabnew 0 1655tabnew 1 1656vnew a.1 1657tabnew 2 1658vnew a.2 1659vnew b.2 1660vnew c.2 1661 1662py 3 << trim EOF 1663def H(o): 1664return repr ( o ) 1665cb .append('Current tab page: ' + repr(vim.current.tabpage)) 1666cb .append('Current window:' + repr(vim.current.window) + ' : ' + \ 1667H (vim.current.window) +' is ' + H(vim.current.tabpage.window)) 1668cb .append('Current buffer:' + repr(vim.current.buffer) + ' : ' + \ 1669H (vim.current.buffer) +' is ' + H(vim.current.window.buffer)+ \ 1670 'is ' + H(vim.current.tabpage.window.buffer)) 1671del H 1672EOF 1673let expected =<< trim END 1674Current tab page: <tabpage 3> 1675Current window: <window 0>: <window 0> is <window 0> 1676Current buffer: <buffer c.2>: <buffer c.2> is <buffer c.2> is <buffer c.2> 1677END 1678call assert_equal ( expected , getbufline ( bufnr ( 'Xfile' ), 2 , '$' )) 1679call deletebufline ( bufnr ( 'Xfile' ), 1 , '$' ) 1680 1681" Assigning: fails 1682py 3 << trim EOF 1683try : 1684vim .current.window = vim.tabpages[0].window 1685except ValueError: 1686cb .append('ValueError at assigning foreign tab window') 1687 1688for attr in ( 'window' , 'tabpage', 'buffer'): 1689try : 1690setattr (vim.current, attr, None) 1691except TypeError: 1692cb .append('Type error at assigning None to vim.current.' + attr) 1693del attr 1694EOF 1695 1696let expected =<< trim END 1697ValueError at assigning foreign tab window 1698Type error at assigning None to vim.current.window 1699Type error at assigning None to vim.current.tabpage 1700Type error at assigning None to vim.current.buffer 1701END 1702call assert_equal ( expected , getbufline ( bufnr ( 'Xfile' ), 2 , '$' )) 1703call deletebufline ( bufnr ( 'Xfile' ), 1 , '$' ) 1704 1705call setbufline ( bufnr ( 'Xfile' ), 1 , 'python interface' ) 1706py 3 << trim EOF 1707 #Assigning: success 1708vim .current.tabpage = vim.tabpages[-2] 1709vim .current.buffer = cb 1710vim .current.window = vim.windows[0] 1711vim .current.window.cursor = (len(vim.current.buffer), 0) 1712cb .append('Current tab page: ' + repr(vim.current.tabpage)) 1713cb .append('Current window: ' + repr(vim.current.window)) 1714cb .append('Current buffer: ' + repr(vim.current.buffer)) 1715cb .append('Current line: ' + repr(vim.current.line)) 1716EOF 1717 1718let expected =<< trim END 1719Current tab page: <tabpage 2> 1720Current window: <window 0> 1721Current buffer: <buffer Xfile> 1722Current line: 'python interface' 1723END 1724call assert_equal ( expected , getbufline ( bufnr ( 'Xfile' ), 2 , '$' )) 1725call deletebufline ( bufnr ( 'Xfile' ), 1 , '$' ) 1726 1727py 3 << trim EOF 1728ws = list(vim.windows) 1729ts = list(vim.tabpages) 1730for b in vim . buffers : 1731if b is not cb: 1732vim .command('bwipeout! ' + str(b.number)) 1733del b 1734cb .append('w.valid: ' + repr([w.valid for w in ws])) 1735cb .append('t.valid: ' + repr([t.valid for t in ts])) 1736del w 1737del t 1738del ts 1739del ws 1740EOF 1741let expected =<< trim END 1742w.valid: [True, False] 1743t.valid: [True, False, True, False] 1744END 1745call assert_equal ( expected , getbufline ( bufnr ( 'Xfile' ), 2 , '$' )) 1746 %bw ! 1747endfunc 1748 1749" Test types 1750func Test_python3_types () 1751throw 'Skipped: Nvim does not support vim.bindeval()' 1752 %d 1753py 3 cb = vim .current .buffer 1754py 3 << trim EOF 1755for expr, attr in ( 1756 ('vim.vars', 'Dictionary'), 1757 ('vim.options', 'Options'), 1758 ('vim.bindeval("{}")', 'Dictionary'), 1759 ('vim.bindeval("[]")', 'List'), 1760 ('vim.bindeval("function (\'tr\')")', 'Function'), 1761 ('vim.current.buffer', 'Buffer'), 1762 ('vim.current.range', 'Range'), 1763 ('vim.current.window', 'Window'), 1764 ('vim.current.tabpage', 'TabPage'), 1765) : 1766cb .append(expr +':' + attr +':' + \ 1767repr (type(eval(expr)) is getattr(vim, attr))) 1768del expr 1769del attr 1770EOF 1771let expected =<< trim END 1772vim.vars:Dictionary:True 1773vim.options:Options:True 1774vim.bindeval("{}"):Dictionary:True 1775vim.bindeval("[]"):List:True 1776vim.bindeval("function('tr')"):Function:True 1777vim.current.buffer:Buffer:True 1778vim.current.range:Range:True 1779vim.current.window:Window:True 1780vim.current.tabpage:TabPage:True 1781END 1782call assert_equal ( expected , getline ( 2 , '$' )) 1783endfunc 1784 1785" Test __dir__() method 1786func Test_python3_dir_method () 1787throw 'Skipped: Nvim does not support vim.bindeval()' 1788 %d 1789py 3 cb = vim .current .buffer 1790py 3 << trim EOF 1791for name, o in ( 1792 ('current', vim.current), 1793 ('buffer', vim.current.buffer), 1794 ('window', vim.current.window), 1795 ('tabpage', vim.current.tabpage), 1796 ('range', vim.current.range), 1797 ('dictionary', vim.bindeval('{}')), 1798 ('list', vim.bindeval('[]')), 1799 ('function ', vim.bindeval('function ("tr")')), 1800 ('output', sys.stdout), 1801) : 1802cb .append(name +':' +',' .join(dir(o))) 1803del name 1804del o 1805EOF 1806let expected =<< trim END 1807current:__dir__,buffer,line,range,tabpage,window 1808buffer:__dir__,append,mark,name,number,options,range,valid,vars 1809window:__dir__,buffer,col,cursor,height,number,options,row,tabpage,valid,vars,width 1810tabpage:__dir__,number,valid,vars,window,windows 1811range:__dir__,append,end,start 1812dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values 1813list:__dir__,extend,locked 1814function:__dir__,args,auto_rebind,self,softspace 1815output:__dir__,close,closed,flush,isatty,readable,seekable,softspace,writable,write,writelines 1816END 1817call assert_equal ( expected , getline ( 2 , '$' )) 1818endfunc 1819 1820" Test vim.*.__new__ 1821func Test_python3_new () 1822throw "Skipped: Nvim: 'LegacyVim' object has no attribute 'Dictionary'" 1823call assert_equal ({}, py3eval ( 'vim.Dictionary({})' )) 1824call assert_equal ({ 'a' : 1 }, py3eval ( 'vim.Dictionary(a=1)' )) 1825call assert_equal ({ 'a' : 1 }, py3eval ( 'vim.Dictionary(((''a'', 1),))' )) 1826call assert_equal ([], py3eval ( 'vim.List()' )) 1827call assert_equal ([ 'a' , 'b' , 'c' , '7' ], py3eval ( 'vim.List(iter(''abc7''))' )) 1828call assert_equal ( function ( 'tr' ), py3eval ( 'vim.Function(''tr'')' )) 1829call assert_equal ( function ( 'tr' , [ 123 , 3 , 4 ]), 1830 \py3eval ( 'vim.Function(''tr'', args=[123, 3, 4])' )) 1831call assert_equal ( function ( 'tr' ), py3eval ( 'vim.Function(''tr'', args=[])' )) 1832call assert_equal ( function ( 'tr' , {}), 1833 \py3eval ( 'vim.Function(''tr'', self={})' )) 1834call assert_equal ( function ( 'tr' , [ 123 , 3 , 4 ], {}), 1835 \py3eval ( 'vim.Function(''tr'', args=[123, 3, 4], self={})' )) 1836call assert_equal ( function ( 'tr' ), 1837 \py3eval ( 'vim.Function(''tr'', auto_rebind=False)' )) 1838call assert_equal ( function ( 'tr' , [ 123 , 3 , 4 ]), 1839 \py3eval ( 'vim.Function(''tr'', args=[123, 3, 4], auto_rebind=False)' )) 1840call assert_equal ( function ( 'tr' ), 1841 \py3eval ( 'vim.Function(''tr'', args=[], auto_rebind=False)' )) 1842call assert_equal ( function ( 'tr' , {}), 1843 \py3eval ( 'vim.Function(''tr'', self={}, auto_rebind=False)' )) 1844call assert_equal ( function ( 'tr' , [ 123 , 3 , 4 ], {}), 1845 \py3eval ( 'vim.Function(''tr'', args=[123, 3, 4], self={}, auto_rebind=False)' )) 1846endfunc 1847 1848" Test vim.Function 1849func Test_python3_vim_func () 1850throw 'Skipped: Nvim does not support vim.bindeval()' 1851function Args (...) 1852return a: 000 1853endfunc 1854 1855function SelfArgs (...) dict 1856return [ a: 000 , self ] 1857endfunc 1858 1859" The following four lines should not crash 1860let Pt = function ( 'tr' , [[]], { 'l' : []}) 1861py 3 Pt = vim .bindeval ('Pt' ) 1862unlet Pt 1863py 3 del Pt 1864 1865 %bw ! 1866py 3 cb = vim .current .buffer 1867py 3 << trim EOF 1868def ecall(out_prefix, func, *args, **kwargs): 1869line = out_prefix +': ' 1870try : 1871ret = func(*args, **kwargs) 1872except Exception: 1873line +='!exception: ' + emsg(sys.exc_info()) 1874else : 1875line +='!result: ' + str(vim.Function('string')(ret),'utf-8' ) 1876cb .append(line) 1877a = vim.Function('Args') 1878pa 1 = vim.Function('Args', args=['abcArgsPA1']) 1879pa 2 = vim.Function('Args', args=[]) 1880pa 3 = vim.Function('Args', args=['abcArgsPA3'], self={'abcSelfPA3':'abcSelfPA3Val' }) 1881pa 4 = vim.Function('Args', self={'abcSelfPA4':'abcSelfPA4Val' }) 1882cb .append('a: ' + repr(a)) 1883cb .append('pa1: ' + repr(pa1)) 1884cb .append('pa2: ' + repr(pa2)) 1885cb .append('pa3: ' + repr(pa3)) 1886cb .append('pa4: ' + repr(pa4)) 1887sa = vim.Function('SelfArgs') 1888psa 1 = vim.Function('SelfArgs', args=['abcArgsPSA1']) 1889psa 2 = vim.Function('SelfArgs', args=[]) 1890psa 3 = vim.Function('SelfArgs', args=['abcArgsPSA3'], self={'abcSelfPSA3':'abcSelfPSA3Val' }) 1891psa 4 = vim.Function('SelfArgs', self={'abcSelfPSA4':'abcSelfPSA4Val' }) 1892psa 5 = vim.Function('SelfArgs', self={'abcSelfPSA5':'abcSelfPSA5Val' }, auto_rebind=0) 1893psa 6 = vim.Function('SelfArgs', args=['abcArgsPSA6'], self={'abcSelfPSA6':'abcSelfPSA6Val' }, auto_rebind=()) 1894psa 7 = vim.Function('SelfArgs', args=['abcArgsPSA7'], auto_rebind=[]) 1895psa 8 = vim.Function('SelfArgs', auto_rebind=False) 1896psa 9 = vim.Function('SelfArgs', self={'abcSelfPSA9':'abcSelfPSA9Val' }, auto_rebind=True) 1897psaA = vim.Function('SelfArgs', args=['abcArgsPSAA'], self={'abcSelfPSAA':'abcSelfPSAAVal' }, auto_rebind=1) 1898psaB = vim.Function('SelfArgs', args=['abcArgsPSAB'], auto_rebind={'abcARPSAB':'abcARPSABVal' }) 1899psaC = vim.Function('SelfArgs', auto_rebind=['abcARPSAC']) 1900cb .append('sa: ' + repr(sa)) 1901cb .append('psa1: ' + repr(psa1)) 1902cb .append('psa2: ' + repr(psa2)) 1903cb .append('psa3: ' + repr(psa3)) 1904cb .append('psa4: ' + repr(psa4)) 1905cb .append('psa5: ' + repr(psa5)) 1906cb .append('psa6: ' + repr(psa6)) 1907cb .append('psa7: ' + repr(psa7)) 1908cb .append('psa8: ' + repr(psa8)) 1909cb .append('psa9: ' + repr(psa9)) 1910cb .append('psaA: ' + repr(psaA)) 1911cb .append('psaB: ' + repr(psaB)) 1912cb .append('psaC: ' + repr(psaC)) 1913 1914psar = vim.Function('SelfArgs', args=[{'abcArgsPSAr':'abcArgsPSArVal' }], self={'abcSelfPSAr':'abcSelfPSArVal' }) 1915psar .args[0]['abcArgsPSAr2'] = [psar.self, psar.args[0]] 1916psar .self['rec'] = psar 1917psar .self['self'] = psar.self 1918psar .self['args'] = psar.args 1919 1920try : 1921cb .append('psar: ' + repr(psar)) 1922except Exception: 1923cb .append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) 1924EOF 1925 1926let expected =<< trim END 1927a: <vim.Function 'Args'> 1928pa1: <vim.Function 'Args', args=['abcArgsPA1']> 1929pa2: <vim.Function 'Args'> 1930pa3: <vim.Function 'Args', args=['abcArgsPA3'], self={'abcSelfPA3': 'abcSelfPA3Val'}> 1931pa4: <vim.Function 'Args', self={'abcSelfPA4': 'abcSelfPA4Val'}> 1932sa: <vim.Function 'SelfArgs'> 1933psa1: <vim.Function 'SelfArgs', args=['abcArgsPSA1']> 1934psa2: <vim.Function 'SelfArgs'> 1935psa3: <vim.Function 'SelfArgs', args=['abcArgsPSA3'], self={'abcSelfPSA3': 'abcSelfPSA3Val'}> 1936psa4: <vim.Function 'SelfArgs', self={'abcSelfPSA4': 'abcSelfPSA4Val'}> 1937psa5: <vim.Function 'SelfArgs', self={'abcSelfPSA5': 'abcSelfPSA5Val'}> 1938psa6: <vim.Function 'SelfArgs', args=['abcArgsPSA6'], self={'abcSelfPSA6': 'abcSelfPSA6Val'}> 1939psa7: <vim.Function 'SelfArgs', args=['abcArgsPSA7']> 1940psa8: <vim.Function 'SelfArgs'> 1941psa9: <vim.Function 'SelfArgs', self={'abcSelfPSA9': 'abcSelfPSA9Val'}, auto_rebind=True> 1942psaA: <vim.Function 'SelfArgs', args=['abcArgsPSAA'], self={'abcSelfPSAA': 'abcSelfPSAAVal'}, auto_rebind=True> 1943psaB: <vim.Function 'SelfArgs', args=['abcArgsPSAB']> 1944psaC: <vim.Function 'SelfArgs'> 1945psar: <vim.Function 'SelfArgs', args=[{'abcArgsPSAr2': [{'rec': function('SelfArgs', [{...}], {...}), 'self': {...}, 'abcSelfPSAr': 'abcSelfPSArVal', 'args': [{...}]}, {...}], 'abcArgsPSAr': 'abcArgsPSArVal'}], self={'rec': function('SelfArgs', [{'abcArgsPSAr2': [{...}, {...}], 'abcArgsPSAr': 'abcArgsPSArVal'}], {...}), 'self': {...}, 'abcSelfPSAr': 'abcSelfPSArVal', 'args': [{'abcArgsPSAr2': [{...}, {...}], 'abcArgsPSAr': 'abcArgsPSArVal'}]}> 1946END 1947call assert_equal ( expected , getline ( 2 , '$' )) 1948 %d 1949 1950call assert_equal ( function ( 'Args' ), py3eval ( 'a' )) 1951call assert_equal ( function ( 'Args' , [ 'abcArgsPA1' ]), py3eval ( 'pa1' )) 1952call assert_equal ( function ( 'Args' ), py3eval ( 'pa2' )) 1953call assert_equal ( function ( 'Args' , [ 'abcArgsPA3' ], { 'abcSelfPA3' : 'abcSelfPA3Val' }), py3eval ( 'pa3' )) 1954call assert_equal ( function ( 'Args' , { 'abcSelfPA4' : 'abcSelfPA4Val' }), py3eval ( 'pa4' )) 1955call assert_equal ( function ( 'SelfArgs' ), py3eval ( 'sa' )) 1956call assert_equal ( function ( 'SelfArgs' , [ 'abcArgsPSA1' ]), py3eval ( 'psa1' )) 1957call assert_equal ( function ( 'SelfArgs' ), py3eval ( 'psa2' )) 1958call assert_equal ( function ( 'SelfArgs' , [ 'abcArgsPSA3' ], { 'abcSelfPSA3' : 'abcSelfPSA3Val' }), py3eval ( 'psa3' )) 1959call assert_equal ( function ( 'SelfArgs' , { 'abcSelfPSA4' : 'abcSelfPSA4Val' }), py3eval ( 'psa4' )) 1960call assert_equal ( function ( 'SelfArgs' , { 'abcSelfPSA5' : 'abcSelfPSA5Val' }), py3eval ( 'psa5' )) 1961call assert_equal ( function ( 'SelfArgs' , [ 'abcArgsPSA6' ], { 'abcSelfPSA6' : 'abcSelfPSA6Val' }), py3eval ( 'psa6' )) 1962call assert_equal ( function ( 'SelfArgs' , [ 'abcArgsPSA7' ]), py3eval ( 'psa7' )) 1963call assert_equal ( function ( 'SelfArgs' ), py3eval ( 'psa8' )) 1964call assert_equal ( function ( 'SelfArgs' , { 'abcSelfPSA9' : 'abcSelfPSA9Val' }), py3eval ( 'psa9' )) 1965call assert_equal ( function ( 'SelfArgs' , [ 'abcArgsPSAA' ], { 'abcSelfPSAA' : 'abcSelfPSAAVal' }), py3eval ( 'psaA' )) 1966call assert_equal ( function ( 'SelfArgs' , [ 'abcArgsPSAB' ]), py3eval ( 'psaB' )) 1967call assert_equal ( function ( 'SelfArgs' ), py3eval ( 'psaC' )) 1968 1969let res = [] 1970for v in [ 'sa' , 'psa1' , 'psa2' , 'psa3' , 'psa4' , 'psa5' , 'psa6' , 'psa7' , 1971 \'psa8' , 'psa9' , 'psaA' , 'psaB' , 'psaC' ] 1972let d = { 'f' : py3eval ( v )} 1973call add ( res , 'd.' .. v .. '(): ' .. string ( d . f ())) 1974endfor 1975 1976let expected =<< trim END 1977d.sa(): [[], {'f': function('SelfArgs')}] 1978d.psa1(): [['abcArgsPSA1'], {'f': function('SelfArgs', ['abcArgsPSA1'])}] 1979d.psa2(): [[], {'f': function('SelfArgs')}] 1980d.psa3(): [['abcArgsPSA3'], {'abcSelfPSA3': 'abcSelfPSA3Val'}] 1981d.psa4(): [[], {'abcSelfPSA4': 'abcSelfPSA4Val'}] 1982d.psa5(): [[], {'abcSelfPSA5': 'abcSelfPSA5Val'}] 1983d.psa6(): [['abcArgsPSA6'], {'abcSelfPSA6': 'abcSelfPSA6Val'}] 1984d.psa7(): [['abcArgsPSA7'], {'f': function('SelfArgs', ['abcArgsPSA7'])}] 1985d.psa8(): [[], {'f': function('SelfArgs')}] 1986d.psa9(): [[], {'f': function('SelfArgs', {'abcSelfPSA9': 'abcSelfPSA9Val'})}] 1987d.psaA(): [['abcArgsPSAA'], {'f': function('SelfArgs', ['abcArgsPSAA'], {'abcSelfPSAA': 'abcSelfPSAAVal'})}] 1988d.psaB(): [['abcArgsPSAB'], {'f': function('SelfArgs', ['abcArgsPSAB'])}] 1989d.psaC(): [[], {'f': function('SelfArgs')}] 1990END 1991call assert_equal ( expected , res ) 1992 1993py 3 ecall ('a()' ,a , ) 1994py 3 ecall ('pa1()' ,pa1 , ) 1995py 3 ecall ('pa2()' ,pa2 , ) 1996py 3 ecall ('pa3()' ,pa3 , ) 1997py 3 ecall ('pa4()' ,pa4 , ) 1998py 3 ecall ('sa()' ,sa , ) 1999py 3 ecall ('psa1()' ,psa1 , ) 2000py 3 ecall ('psa2()' ,psa2 , ) 2001py 3 ecall ('psa3()' ,psa3 , ) 2002py 3 ecall ('psa4()' ,psa4 , ) 2003 2004py 3 ecall ('a(42, 43)' ,a ,42 ,43 ) 2005py 3 ecall ('pa1(42, 43)' ,pa1 ,42 ,43 ) 2006py 3 ecall ('pa2(42, 43)' ,pa2 ,42 ,43 ) 2007py 3 ecall ('pa3(42, 43)' ,pa3 ,42 ,43 ) 2008py 3 ecall ('pa4(42, 43)' ,pa4 ,42 ,43 ) 2009py 3 ecall ('sa(42, 43)' ,sa ,42 ,43 ) 2010py 3 ecall ('psa1(42, 43)' ,psa1 ,42 ,43 ) 2011py 3 ecall ('psa2(42, 43)' ,psa2 ,42 ,43 ) 2012py 3 ecall ('psa3(42, 43)' ,psa3 ,42 ,43 ) 2013py 3 ecall ('psa4(42, 43)' ,psa4 ,42 ,43 ) 2014 2015py 3 ecall ('a(42, self={"20": 1})' ,a ,42 ,self = {'20' :1 }) 2016py 3 ecall ('pa1(42, self={"20": 1})' ,pa1 ,42 ,self = {'20' :1 }) 2017py 3 ecall ('pa2(42, self={"20": 1})' ,pa2 ,42 ,self = {'20' :1 }) 2018py 3 ecall ('pa3(42, self={"20": 1})' ,pa3 ,42 ,self = {'20' :1 }) 2019py 3 ecall ('pa4(42, self={"20": 1})' ,pa4 ,42 ,self = {'20' :1 }) 2020py 3 ecall ('sa(42, self={"20": 1})' ,sa ,42 ,self = {'20' :1 }) 2021py 3 ecall ('psa1(42, self={"20": 1})' ,psa1 ,42 ,self = {'20' :1 }) 2022py 3 ecall ('psa2(42, self={"20": 1})' ,psa2 ,42 ,self = {'20' :1 }) 2023py 3 ecall ('psa3(42, self={"20": 1})' ,psa3 ,42 ,self = {'20' :1 }) 2024py 3 ecall ('psa4(42, self={"20": 1})' ,psa4 ,42 ,self = {'20' :1 }) 2025 2026py 3 ecall ('a(self={"20": 1})' ,a ,self = {'20' :1 }) 2027py 3 ecall ('pa1(self={"20": 1})' ,pa1 ,self = {'20' :1 }) 2028py 3 ecall ('pa2(self={"20": 1})' ,pa2 ,self = {'20' :1 }) 2029py 3 ecall ('pa3(self={"20": 1})' ,pa3 ,self = {'20' :1 }) 2030py 3 ecall ('pa4(self={"20": 1})' ,pa4 ,self = {'20' :1 }) 2031py 3 ecall ('sa(self={"20": 1})' ,sa ,self = {'20' :1 }) 2032py 3 ecall ('psa1(self={"20": 1})' ,psa1 ,self = {'20' :1 }) 2033py 3 ecall ('psa2(self={"20": 1})' ,psa2 ,self = {'20' :1 }) 2034py 3 ecall ('psa3(self={"20": 1})' ,psa3 ,self = {'20' :1 }) 2035py 3 ecall ('psa4(self={"20": 1})' ,psa4 ,self = {'20' :1 }) 2036 2037py 3 << trim EOF 2038def s(v): 2039if v is None : 2040return repr ( v ) 2041else : 2042return str ( vim . Function ( 'string' )( v ), 'utf-8' ) 2043 2044cb .append('a.args: ' + s(a.args)) 2045cb .append('pa1.args: ' + s(pa1.args)) 2046cb .append('pa2.args: ' + s(pa2.args)) 2047cb .append('pa3.args: ' + s(pa3.args)) 2048cb .append('pa4.args: ' + s(pa4.args)) 2049cb .append('sa.args: ' + s(sa.args)) 2050cb .append('psa1.args: ' + s(psa1.args)) 2051cb .append('psa2.args: ' + s(psa2.args)) 2052cb .append('psa3.args: ' + s(psa3.args)) 2053cb .append('psa4.args: ' + s(psa4.args)) 2054 2055cb .append('a.self: ' + s(a.self)) 2056cb .append('pa1.self: ' + s(pa1.self)) 2057cb .append('pa2.self: ' + s(pa2.self)) 2058cb .append('pa3.self: ' + s(pa3.self)) 2059cb .append('pa4.self: ' + s(pa4.self)) 2060cb .append('sa.self: ' + s(sa.self)) 2061cb .append('psa1.self: ' + s(psa1.self)) 2062cb .append('psa2.self: ' + s(psa2.self)) 2063cb .append('psa3.self: ' + s(psa3.self)) 2064cb .append('psa4.self: ' + s(psa4.self)) 2065 2066cb .append('a.name: ' + s(a.name)) 2067cb .append('pa1.name: ' + s(pa1.name)) 2068cb .append('pa2.name: ' + s(pa2.name)) 2069cb .append('pa3.name: ' + s(pa3.name)) 2070cb .append('pa4.name: ' + s(pa4.name)) 2071cb .append('sa.name: ' + s(sa.name)) 2072cb .append('psa1.name: ' + s(psa1.name)) 2073cb .append('psa2.name: ' + s(psa2.name)) 2074cb .append('psa3.name: ' + s(psa3.name)) 2075cb .append('psa4.name: ' + s(psa4.name)) 2076 2077cb .append('a.auto_rebind: ' + s(a.auto_rebind)) 2078cb .append('pa1.auto_rebind: ' + s(pa1.auto_rebind)) 2079cb .append('pa2.auto_rebind: ' + s(pa2.auto_rebind)) 2080cb .append('pa3.auto_rebind: ' + s(pa3.auto_rebind)) 2081cb .append('pa4.auto_rebind: ' + s(pa4.auto_rebind)) 2082cb .append('sa.auto_rebind: ' + s(sa.auto_rebind)) 2083cb .append('psa1.auto_rebind: ' + s(psa1.auto_rebind)) 2084cb .append('psa2.auto_rebind: ' + s(psa2.auto_rebind)) 2085cb .append('psa3.auto_rebind: ' + s(psa3.auto_rebind)) 2086cb .append('psa4.auto_rebind: ' + s(psa4.auto_rebind)) 2087cb .append('psa5.auto_rebind: ' + s(psa5.auto_rebind)) 2088cb .append('psa6.auto_rebind: ' + s(psa6.auto_rebind)) 2089cb .append('psa7.auto_rebind: ' + s(psa7.auto_rebind)) 2090cb .append('psa8.auto_rebind: ' + s(psa8.auto_rebind)) 2091cb .append('psa9.auto_rebind: ' + s(psa9.auto_rebind)) 2092cb .append('psaA.auto_rebind: ' + s(psaA.auto_rebind)) 2093cb .append('psaB.auto_rebind: ' + s(psaB.auto_rebind)) 2094cb .append('psaC.auto_rebind: ' + s(psaC.auto_rebind)) 2095 2096del s 2097 2098del a 2099del pa1 2100del pa2 2101del pa3 2102del pa4 2103del sa 2104del psa1 2105del psa2 2106del psa3 2107del psa4 2108del psa5 2109del psa6 2110del psa7 2111del psa8 2112del psa9 2113del psaA 2114del psaB 2115del psaC 2116del psar 2117 2118del ecall 2119EOF 2120 2121let expected =<< trim END 2122a(): !result: [] 2123pa1(): !result: ['abcArgsPA1'] 2124pa2(): !result: [] 2125pa3(): !result: ['abcArgsPA3'] 2126pa4(): !result: [] 2127sa(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) 2128psa1(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) 2129psa2(): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) 2130psa3(): !result: [['abcArgsPSA3'], {'abcSelfPSA3': 'abcSelfPSA3Val'}] 2131psa4(): !result: [[], {'abcSelfPSA4': 'abcSelfPSA4Val'}] 2132a(42, 43): !result: [42, 43] 2133pa1(42, 43): !result: ['abcArgsPA1', 42, 43] 2134pa2(42, 43): !result: [42, 43] 2135pa3(42, 43): !result: ['abcArgsPA3', 42, 43] 2136pa4(42, 43): !result: [42, 43] 2137sa(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) 2138psa1(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) 2139psa2(42, 43): !exception: error:('Vim:E725: Calling dict function without Dictionary: SelfArgs',) 2140psa3(42, 43): !result: [['abcArgsPSA3', 42, 43], {'abcSelfPSA3': 'abcSelfPSA3Val'}] 2141psa4(42, 43): !result: [[42, 43], {'abcSelfPSA4': 'abcSelfPSA4Val'}] 2142a(42, self={"20": 1}): !result: [42] 2143pa1(42, self={"20": 1}): !result: ['abcArgsPA1', 42] 2144pa2(42, self={"20": 1}): !result: [42] 2145pa3(42, self={"20": 1}): !result: ['abcArgsPA3', 42] 2146pa4(42, self={"20": 1}): !result: [42] 2147sa(42, self={"20": 1}): !result: [[42], {'20': 1}] 2148psa1(42, self={"20": 1}): !result: [['abcArgsPSA1', 42], {'20': 1}] 2149psa2(42, self={"20": 1}): !result: [[42], {'20': 1}] 2150psa3(42, self={"20": 1}): !result: [['abcArgsPSA3', 42], {'20': 1}] 2151psa4(42, self={"20": 1}): !result: [[42], {'20': 1}] 2152a(self={"20": 1}): !result: [] 2153pa1(self={"20": 1}): !result: ['abcArgsPA1'] 2154pa2(self={"20": 1}): !result: [] 2155pa3(self={"20": 1}): !result: ['abcArgsPA3'] 2156pa4(self={"20": 1}): !result: [] 2157sa(self={"20": 1}): !result: [[], {'20': 1}] 2158psa1(self={"20": 1}): !result: [['abcArgsPSA1'], {'20': 1}] 2159psa2(self={"20": 1}): !result: [[], {'20': 1}] 2160psa3(self={"20": 1}): !result: [['abcArgsPSA3'], {'20': 1}] 2161psa4(self={"20": 1}): !result: [[], {'20': 1}] 2162a.args: None 2163pa1.args: ['abcArgsPA1'] 2164pa2.args: None 2165pa3.args: ['abcArgsPA3'] 2166pa4.args: None 2167sa.args: None 2168psa1.args: ['abcArgsPSA1'] 2169psa2.args: None 2170psa3.args: ['abcArgsPSA3'] 2171psa4.args: None 2172a.self: None 2173pa1.self: None 2174pa2.self: None 2175pa3.self: {'abcSelfPA3': 'abcSelfPA3Val'} 2176pa4.self: {'abcSelfPA4': 'abcSelfPA4Val'} 2177sa.self: None 2178psa1.self: None 2179psa2.self: None 2180psa3.self: {'abcSelfPSA3': 'abcSelfPSA3Val'} 2181psa4.self: {'abcSelfPSA4': 'abcSelfPSA4Val'} 2182a.name: 'Args' 2183pa1.name: 'Args' 2184pa2.name: 'Args' 2185pa3.name: 'Args' 2186pa4.name: 'Args' 2187sa.name: 'SelfArgs' 2188psa1.name: 'SelfArgs' 2189psa2.name: 'SelfArgs' 2190psa3.name: 'SelfArgs' 2191psa4.name: 'SelfArgs' 2192a.auto_rebind: 1 2193pa1.auto_rebind: 1 2194pa2.auto_rebind: 1 2195pa3.auto_rebind: 0 2196pa4.auto_rebind: 0 2197sa.auto_rebind: 1 2198psa1.auto_rebind: 1 2199psa2.auto_rebind: 1 2200psa3.auto_rebind: 0 2201psa4.auto_rebind: 0 2202psa5.auto_rebind: 0 2203psa6.auto_rebind: 0 2204psa7.auto_rebind: 1 2205psa8.auto_rebind: 1 2206psa9.auto_rebind: 1 2207psaA.auto_rebind: 1 2208psaB.auto_rebind: 1 2209psaC.auto_rebind: 1 2210END 2211call assert_equal ( expected , getline ( 2 , '$' )) 2212 %bw ! 2213endfunc 2214 2215" Test stdout/stderr 2216func Test_python3_stdin_stderr () 2217throw 'Skipped: TODO: ' 2218let caught_writeerr = 0 2219let caught_writelineerr = 0 2220redir => messages 2221py 3 sys .stdout .write ('abc8' ) ;sys .stdout .write ('def' ) 2222try 2223py 3 sys .stderr .write ('abc9' ) ;sys .stderr .write ('def' ) 2224catch /abc9def/ 2225let caught_writeerr = 1 2226endtry 2227py 3 sys .stdout .writelines (iter ('abcA' )) 2228try 2229py 3 sys .stderr .writelines (iter ('abcB' )) 2230catch /abcB/ 2231let caught_writelineerr = 1 2232endtry 2233redir END 2234call assert_equal ( "\nabc8def\nabcA" , messages ) 2235call assert_equal ( 1 , caught_writeerr ) 2236call assert_equal ( 1 , caught_writelineerr ) 2237endfunc 2238 2239" Test subclassing 2240func Test_python3_subclass () 2241throw "Skipped: Nvim: 'LegacyVim' object has no attribute 'Dictionary'" 2242new 2243func Put (...) 2244return a: 000 2245endfunc 2246 2247py 3 << trim EOF 2248class DupDict(vim.Dictionary): 2249def __setitem__(self, key, value): 2250super (DupDict, self).__setitem__(key, value) 2251super (DupDict, self).__setitem__('dup_' + key, value) 2252dd = DupDict() 2253dd ['a'] ='b' 2254 2255class DupList(vim.List): 2256def __getitem__(self, idx): 2257return [ super ( DupList , self ). __getitem__ ( idx )] * 2 2258 2259dl = DupList() 2260dl 2 = DupList(iter('abcC')) 2261dl .extend(dl2[0]) 2262 2263class DupFun(vim.Function): 2264def __call__(self, arg): 2265return super ( DupFun , self ). __call__ ( arg , arg ) 2266 2267df = DupFun('Put') 2268EOF 2269 2270call assert_equal ([ 'a' , 'dup_a' ], sort ( keys ( py3eval ( 'dd' )))) 2271call assert_equal ([ 'a' , 'a' ], py3eval ( 'dl' )) 2272call assert_equal ([ 'a' , 'b' , 'c' , 'C' ], py3eval ( 'dl2' )) 2273call assert_equal ([ 2 , 2 ], py3eval ( 'df(2)' )) 2274call assert_equal ( 1 , py3eval ( 'dl' ) is# py3eval ( 'dl' )) 2275call assert_equal ( 1 , py3eval ( 'dd' ) is# py3eval ( 'dd' )) 2276call assert_equal ( function ( 'Put' ), py3eval ( 'df' )) 2277delfunction Put 2278py 3 << trim EOF 2279del DupDict 2280del DupList 2281del DupFun 2282del dd 2283del dl 2284del dl2 2285del df 2286EOF 2287close ! 2288endfunc 2289 2290" Test chdir 2291func Test_python3_chdir () 2292throw "Skipped: Nvim: 'LegacyVim' object has no attribute 'Function'" 2293new Xfile 2294py 3 cb = vim .current .buffer 2295py 3 << trim EOF 2296import os 2297fnamemodify = vim.Function('fnamemodify') 2298cb .append(str(fnamemodify('.',':p:h:t' ))) 2299cb .append(vim.eval('@%')) 2300os .chdir('..') 2301path = fnamemodify('.',':p:h:t' ) 2302if path != b 'src' and path != b'src2': 2303 #Running tests from a shadow directory, so move up another level 2304 #This will result in @% looking like shadow/testdir/Xfile, hence the 2305 # slicing to remove the leading path and path separator 2306os .chdir('..') 2307cb .append(str(fnamemodify('.',':p:h:t' ))) 2308cb .append(vim.eval('@%')[len(path)+1:].replace(os.path.sep,'/' )) 2309os .chdir(path) 2310del path 2311else : 2312 #Also accept running from src2/testdir/ forMS-Windows CI. 2313cb .append(str(fnamemodify('.',':p:h:t' ).replace(b'src2', b'src'))) 2314cb .append(vim.eval('@%').replace(os.path.sep,'/' )) 2315del path 2316os .chdir('testdir') 2317cb .append(str(fnamemodify('.',':p:h:t' ))) 2318cb .append(vim.eval('@%')) 2319del fnamemodify 2320EOF 2321call assert_equal ([ "b'testdir'" , 'Xfile' , "b'src'" , 'testdir/Xfile' , 2322 \"b'testdir'" , 'Xfile' ], getline ( 2 , '$' )) 2323close ! 2324endfunc 2325 2326" Test errors 2327func Test_python3_errors () 2328throw 'Skipped: Nvim does not support vim.bindeval()' 2329func F () dict 2330endfunc 2331 2332func D () 2333endfunc 2334 2335new 2336py 3 cb = vim .current .buffer 2337 2338py 3 << trim EOF 2339import os 2340d = vim.Dictionary() 2341ned = vim.Dictionary(foo='bar', baz='abcD') 2342dl = vim.Dictionary(a=1) 2343dl .locked = True 2344l = vim.List() 2345ll = vim.List('abcE') 2346ll .locked = True 2347nel = vim.List('abcO') 2348f = vim.Function('string') 2349fd = vim.Function('F') 2350fdel = vim.Function('D') 2351vim .command('delfunction D') 2352 2353def subexpr_test(expr, name, subexprs): 2354cb .append('>>> Testing %s using %s' % (name, expr)) 2355for subexpr in subexprs : 2356ee (expr % subexpr) 2357cb .append('<<< Finished') 2358 2359def stringtochars_test(expr): 2360return subexpr_test ( expr , 'StringToChars' , ( 2361 '1', #Fail type checks 2362 'b"\\0"', # Fail PyString_AsStringAndSize(object, , NULL) check 2363 '"\\0"', #Fail PyString_AsStringAndSize(bytes, ,NULL) check 2364) ) 2365 2366class Mapping(object): 2367def __init__(self, d): 2368self .d = d 2369 2370def __getitem__(self, key): 2371return self . d [ key ] 2372 2373def keys(self): 2374return self . d . keys () 2375 2376def items(self): 2377return self . d . items () 2378 2379def convertfrompyobject_test(expr, recurse=True): 2380 # pydict_to_tv 2381stringtochars _test(expr %'{%s : 1}' ) 2382if recurse : 2383convertfrompyobject _test(expr %'{"abcF" : %s}' , False) 2384 # pymap_to_tv 2385stringtochars _test(expr %'Mapping({%s : 1})' ) 2386if recurse : 2387convertfrompyobject _test(expr %'Mapping({"abcG" : %s})' , False) 2388 # pyseq_to_tv 2389iter _test(expr) 2390return subexpr_test ( expr , 'ConvertFromPyObject' , ( 2391 'None ', # Not conversible 2392 '{b "" : 1}', # Empty key not allowed 2393 '{"": 1}', # Same, but with unicode object 2394 'FailingMapping ()', # 2395 'FailingMappingKey ()', # 2396 'FailingNumber ()', # 2397) ) 2398 2399def convertfrompymapping_test(expr): 2400convertfrompyobject _test(expr) 2401return subexpr_test ( expr , 'ConvertFromPyMapping' , ( 2402 '[]', 2403) ) 2404 2405def iter_test(expr): 2406return subexpr_test ( expr , '*Iter*' , ( 2407 'FailingIter ()', 2408 'FailingIterNext ()', 2409) ) 2410 2411def number_test(expr, natural=False, unsigned=False): 2412if natural : 2413unsigned = True 2414return subexpr_test ( expr , 'NumberToLong' , ( 2415 '[]', 2416 'None ', 2417) + (('-1',) if unsigned else ()) 2418+ (('0',) if natural else ())) 2419 2420class FailingTrue(object): 2421def __bool__(self): 2422raise NotImplementedError('bool') 2423 2424class FailingIter(object): 2425def __iter__(self): 2426raise NotImplementedError('iter') 2427 2428class FailingIterNext(object): 2429def __iter__(self): 2430return self 2431 2432def __next__(self): 2433raise NotImplementedError('next') 2434 2435class FailingIterNextN(object): 2436def __init__(self, n): 2437self .n = n 2438 2439def __iter__(self): 2440return self 2441 2442def __next__(self): 2443if self . n : 2444self .n -= 1 2445return 1 2446else : 2447raise NotImplementedError('next N') 2448 2449class FailingMappingKey(object): 2450def __getitem__(self, item): 2451raise NotImplementedError('getitem:mappingkey') 2452 2453def keys(self): 2454return list ( "abcH" ) 2455 2456class FailingMapping(object): 2457def __getitem__(self): 2458raise NotImplementedError('getitem:mapping') 2459 2460def keys(self): 2461raise NotImplementedError('keys') 2462 2463class FailingList(list): 2464def __getitem__(self, idx): 2465if i == 2 : 2466raise NotImplementedError('getitem:list') 2467else : 2468return super ( FailingList , self ). __getitem__ ( idx ) 2469 2470class NoArgsCall(object): 2471def __call__(self): 2472pass 2473 2474class FailingCall(object): 2475def __call__(self, path): 2476raise NotImplementedError('call') 2477 2478class FailingNumber(object): 2479def __int__(self): 2480raise NotImplementedError('int') 2481 2482cb .append("> Output") 2483cb .append(">> OutputSetattr") 2484ee ('del sys.stdout.softspace') 2485number _test('sys.stdout.softspace = %s', unsigned=True) 2486number _test('sys.stderr.softspace = %s', unsigned=True) 2487ee ('assert sys.stdout.isatty()==False') 2488ee ('assert sys.stdout.seekable()==False') 2489ee ('sys.stdout.close()') 2490ee ('sys.stdout.flush()') 2491ee ('assert sys.stderr.isatty()==False') 2492ee ('assert sys.stderr.seekable()==False') 2493ee ('sys.stderr.close()') 2494ee ('sys.stderr.flush()') 2495ee ('sys.stdout.attr = None') 2496cb .append(">> OutputWrite") 2497ee ('assert sys.stdout.writable()==True') 2498ee ('assert sys.stdout.readable()==False') 2499ee ('assert sys.stderr.writable()==True') 2500ee ('assert sys.stderr.readable()==False') 2501ee ('assert sys.stdout.closed()==False') 2502ee ('assert sys.stderr.closed()==False') 2503ee ('assert sys.stdout.errors=="strict"') 2504ee ('assert sys.stderr.errors=="strict"') 2505ee ('assert sys.stdout.encoding==sys.stderr.encoding') 2506ee ('sys.stdout.write(None)') 2507cb .append(">> OutputWriteLines") 2508ee ('sys.stdout.writelines(None)') 2509ee ('sys.stdout.writelines([1])') 2510iter _test('sys.stdout.writelines(%s)') 2511cb .append("> VimCommand") 2512stringtochars _test('vim.command(%s)') 2513ee ('vim.command("", 2)') 2514 #!Not checked: vim->python exceptions translating: checked later 2515cb .append("> VimToPython") 2516 #!Not checked: everything: needs errors in internal python functions 2517cb .append("> VimEval") 2518stringtochars _test('vim.eval(%s)') 2519ee ('vim.eval("", FailingTrue())') 2520 #!Not checked: everything: needs errors in internal python functions 2521cb .append("> VimEvalPy") 2522stringtochars _test('vim.bindeval(%s)') 2523ee ('vim.eval("", 2)') 2524 #!Not checked: vim->python exceptions translating: checked later 2525cb .append("> VimStrwidth") 2526stringtochars _test('vim.strwidth(%s)') 2527cb .append("> VimForeachRTP") 2528ee ('vim.foreach_rtp(None)') 2529ee ('vim.foreach_rtp(NoArgsCall())') 2530ee ('vim.foreach_rtp(FailingCall())') 2531ee ('vim.foreach_rtp(int, 2)') 2532cb .append('> import') 2533old _rtp = vim.options['rtp'] 2534vim .options['rtp'] = os.getcwd().replace('\\','\\\\' ).replace(',','\\,' ) 2535ee ('import xxx_no_such_module_xxx') 2536ee ('import failing_import') 2537ee ('import failing') 2538vim .options['rtp'] = old_rtp 2539del old_rtp 2540cb .append("> Options") 2541cb .append(">> OptionsItem") 2542ee ('vim.options["abcQ"]') 2543ee ('vim.options[""]') 2544stringtochars _test('vim.options[%s]') 2545cb .append(">> OptionsContains") 2546stringtochars _test('%s in vim.options') 2547cb .append("> Dictionary") 2548cb .append(">> DictionaryConstructor") 2549ee ('vim.Dictionary("abcI")') 2550 ##!Not checked: py_dict_alloc failure 2551cb .append(">> DictionarySetattr") 2552ee ('del d.locked') 2553ee ('d.locked = FailingTrue()') 2554ee ('vim.vvars.locked = False') 2555ee ('d.scope = True') 2556ee ('d.xxx = True') 2557cb .append(">> _DictionaryItem") 2558ee ('d.get("a", 2, 3)') 2559stringtochars _test('d.get(%s)') 2560ee ('d.pop("a")') 2561ee ('dl.pop("a")') 2562cb .append(">> DictionaryContains") 2563ee ('"" in d') 2564ee ('0 in d') 2565cb .append(">> DictionaryIterNext") 2566ee ('for i in ned: ned["a"] = 1') 2567del i 2568cb .append(">> DictionaryAssItem") 2569ee ('dl["b"] = 1') 2570stringtochars _test('d[%s] = 1') 2571convertfrompyobject _test('d["a"] = %s') 2572cb .append(">> DictionaryUpdate") 2573cb .append(">>> kwargs") 2574cb .append(">>> iter") 2575ee ('d.update(FailingMapping())') 2576ee ('d.update([FailingIterNext()])') 2577ee ('d.update([FailingIterNextN(1)])') 2578iter _test('d.update(%s)') 2579convertfrompyobject _test('d.update(%s)') 2580stringtochars _test('d.update(((%s, 0),))') 2581convertfrompyobject _test('d.update((("a", %s),))') 2582cb .append(">> DictionaryPopItem") 2583ee ('d.popitem(1, 2)') 2584cb .append(">> DictionaryHasKey") 2585ee ('d.has_key()') 2586cb .append("> List") 2587cb .append(">> ListConstructor") 2588ee ('vim.List(1, 2)') 2589ee ('vim.List(a=1)') 2590iter _test('vim.List(%s)') 2591convertfrompyobject _test('vim.List([%s])') 2592cb .append(">> ListItem") 2593ee ('l[1000]') 2594cb .append(">> ListAssItem") 2595ee ('ll[1] = 2') 2596ee ('l[1000] = 3') 2597cb .append(">> ListAssSlice") 2598ee ('ll[1:100] ="abcJ" ') 2599iter _test('l[:] = %s') 2600ee ('nel[1:10:2] ="abcK" ') 2601cb .append(repr(tuple(nel))) 2602ee ('nel[1:10:2] ="a" ') 2603cb .append(repr(tuple(nel))) 2604ee ('nel[1:1:-1] ="a" ') 2605cb .append(repr(tuple(nel))) 2606ee ('nel[:] = FailingIterNextN(2)') 2607cb .append(repr(tuple(nel))) 2608convertfrompyobject _test('l[:] = [%s]') 2609cb .append(">> ListConcatInPlace") 2610iter _test('l.extend(%s)') 2611convertfrompyobject _test('l.extend([%s])') 2612cb .append(">> ListSetattr") 2613ee ('del l.locked') 2614ee ('l.locked = FailingTrue()') 2615ee ('l.xxx = True') 2616cb .append("> Function") 2617cb .append(">> FunctionConstructor") 2618cb .append(">>> FunctionConstructor") 2619ee ('vim.Function("123")') 2620ee ('vim.Function("xxx_non_existent_function_xxx")') 2621ee ('vim.Function("xxx#non#existent#function#xxx")') 2622ee ('vim.Function("xxx_non_existent_function_xxx2", args=[])') 2623ee ('vim.Function("xxx_non_existent_function_xxx3", self={})') 2624ee ('vim.Function("xxx_non_existent_function_xxx4", args=[], self={})') 2625cb .append(">>> FunctionNew") 2626ee ('vim.Function("tr", self="abcFuncSelf")') 2627ee ('vim.Function("tr", args=427423)') 2628ee ('vim.Function("tr", self="abcFuncSelf2", args="abcFuncArgs2")') 2629ee ('vim.Function(self="abcFuncSelf2", args="abcFuncArgs2")') 2630ee ('vim.Function("tr","" , self="abcFuncSelf2", args="abcFuncArgs2")') 2631ee ('vim.Function("tr","" )') 2632cb .append(">> FunctionCall") 2633convertfrompyobject _test('f(%s)') 2634convertfrompymapping _test('fd(self=%s)') 2635cb .append("> TabPage") 2636cb .append(">> TabPageAttr") 2637ee ('vim.current.tabpage.xxx') 2638cb .append("> TabList") 2639cb .append(">> TabListItem") 2640ee ('vim.tabpages[1000]') 2641cb .append("> Window") 2642cb .append(">> WindowAttr") 2643ee ('vim.current.window.xxx') 2644cb .append(">> WindowSetattr") 2645ee ('vim.current.window.buffer = 0') 2646ee ('vim.current.window.cursor = (100000000, 100000000)') 2647ee ('vim.current.window.cursor = True') 2648number _test('vim.current.window.height = %s', unsigned=True) 2649number _test('vim.current.window.width = %s', unsigned=True) 2650ee ('vim.current.window.xxxxxx = True') 2651cb .append("> WinList") 2652cb .append(">> WinListItem") 2653ee ('vim.windows[1000]') 2654cb .append("> Buffer") 2655cb .append(">> StringToLine (indirect)") 2656ee ('vim.current.buffer[0] ="\\na" ') 2657ee ('vim.current.buffer[0] = b"\\na"') 2658cb .append(">> SetBufferLine (indirect)") 2659ee ('vim.current.buffer[0] = True') 2660cb .append(">> SetBufferLineList (indirect)") 2661ee ('vim.current.buffer[:] = True') 2662ee ('vim.current.buffer[:] = ["\\na","bc" ]') 2663cb .append(">> InsertBufferLines (indirect)") 2664ee ('vim.current.buffer.append(None)') 2665ee ('vim.current.buffer.append(["\\na","bc" ])') 2666ee ('vim.current.buffer.append("\\nbc")') 2667cb .append(">> RBItem") 2668ee ('vim.current.buffer[100000000]') 2669cb .append(">> RBAsItem") 2670ee ('vim.current.buffer[100000000] ="" ') 2671cb .append(">> BufferAttr") 2672ee ('vim.current.buffer.xxx') 2673cb .append(">> BufferSetattr") 2674ee ('vim.current.buffer.name = True') 2675ee ('vim.current.buffer.xxx = True') 2676cb .append(">> BufferMark") 2677ee ('vim.current.buffer.mark(0)') 2678ee ('vim.current.buffer.mark("abcM")') 2679ee ('vim.current.buffer.mark("!")') 2680cb .append(">> BufferRange") 2681ee ('vim.current.buffer.range(1, 2, 3)') 2682cb .append("> BufMap") 2683cb .append(">> BufMapItem") 2684ee ('vim.buffers[100000000]') 2685number _test('vim.buffers[%s]', natural=True) 2686cb .append("> Current") 2687cb .append(">> CurrentGetattr") 2688ee ('vim.current.xxx') 2689cb .append(">> CurrentSetattr") 2690ee ('vim.current.line = True') 2691ee ('vim.current.buffer = True') 2692ee ('vim.current.window = True') 2693ee ('vim.current.tabpage = True') 2694ee ('vim.current.xxx = True') 2695del d 2696del ned 2697del dl 2698del l 2699del ll 2700del nel 2701del f 2702del fd 2703del fdel 2704del subexpr_test 2705del stringtochars_test 2706del Mapping 2707del convertfrompyobject_test 2708del convertfrompymapping_test 2709del iter_test 2710del number_test 2711del FailingTrue 2712del FailingIter 2713del FailingIterNext 2714del FailingIterNextN 2715del FailingMapping 2716del FailingMappingKey 2717del FailingList 2718del NoArgsCall 2719del FailingCall 2720del FailingNumber 2721EOF 2722delfunction F 2723 2724let expected =<< trim END 2725> Output 2726>> OutputSetattr 2727del sys.stdout.softspace:(<class 'AttributeError'>, AttributeError('cannot delete OutputObject attributes',)) 2728>>> Testing NumberToLong using sys.stdout.softspace = %s 2729sys.stdout.softspace = []:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got list',)) 2730sys.stdout.softspace = None:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got NoneType',)) 2731sys.stdout.softspace = -1:(<class 'ValueError'>, ValueError('number must be greater or equal to zero',)) 2732<<< Finished 2733>>> Testing NumberToLong using sys.stderr.softspace = %s 2734sys.stderr.softspace = []:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got list',)) 2735sys.stderr.softspace = None:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got NoneType',)) 2736sys.stderr.softspace = -1:(<class 'ValueError'>, ValueError('number must be greater or equal to zero',)) 2737<<< Finished 2738assert sys.stdout.isatty()==False:NOT FAILED 2739assert sys.stdout.seekable()==False:NOT FAILED 2740sys.stdout.close():NOT FAILED 2741sys.stdout.flush():NOT FAILED 2742assert sys.stderr.isatty()==False:NOT FAILED 2743assert sys.stderr.seekable()==False:NOT FAILED 2744sys.stderr.close():NOT FAILED 2745sys.stderr.flush():NOT FAILED 2746sys.stdout.attr = None:(<class 'AttributeError'>, AttributeError('invalid attribute: attr',)) 2747>> OutputWrite 2748assert sys.stdout.writable()==True:NOT FAILED 2749assert sys.stdout.readable()==False:NOT FAILED 2750assert sys.stderr.writable()==True:NOT FAILED 2751assert sys.stderr.readable()==False:NOT FAILED 2752assert sys.stdout.closed()==False:NOT FAILED 2753assert sys.stderr.closed()==False:NOT FAILED 2754assert sys.stdout.errors=="strict":NOT FAILED 2755assert sys.stderr.errors=="strict":NOT FAILED 2756assert sys.stdout.encoding==sys.stderr.encoding:NOT FAILED 2757sys.stdout.write(None):(<class 'TypeError'>, TypeError("Can't convert 'NoneType' object to str implicitly",)) 2758>> OutputWriteLines 2759sys.stdout.writelines(None):(<class 'TypeError'>, TypeError("'NoneType' object is not iterable",)) 2760sys.stdout.writelines([1]):(<class 'TypeError'>, TypeError("Can't convert 'int' object to str implicitly",)) 2761>>> Testing *Iter* using sys.stdout.writelines(%s) 2762sys.stdout.writelines(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError('iter',)) 2763sys.stdout.writelines(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError('next',)) 2764<<< Finished 2765> VimCommand 2766>>> Testing StringToChars using vim.command(%s) 2767vim.command(1):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2768vim.command(b"\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2769vim.command("\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2770<<< Finished 2771vim.command("", 2):(<class 'TypeError'>, TypeError('command() takes exactly one argument (2 given)',)) 2772> VimToPython 2773> VimEval 2774>>> Testing StringToChars using vim.eval(%s) 2775vim.eval(1):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2776vim.eval(b"\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2777vim.eval("\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2778<<< Finished 2779vim.eval("", FailingTrue()):(<class 'TypeError'>, TypeError('function takes exactly 1 argument (2 given)',)) 2780> VimEvalPy 2781>>> Testing StringToChars using vim.bindeval(%s) 2782vim.bindeval(1):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2783vim.bindeval(b"\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2784vim.bindeval("\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2785<<< Finished 2786vim.eval("", 2):(<class 'TypeError'>, TypeError('function takes exactly 1 argument (2 given)',)) 2787> VimStrwidth 2788>>> Testing StringToChars using vim.strwidth(%s) 2789vim.strwidth(1):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2790vim.strwidth(b"\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2791vim.strwidth("\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2792<<< Finished 2793> VimForeachRTP 2794vim.foreach_rtp(None):(<class 'TypeError'>, TypeError("'NoneType' object is not callable",)) 2795vim.foreach_rtp(NoArgsCall()):(<class 'TypeError'>, TypeError('__call__() takes exactly 1 positional argument (2 given)',)) 2796vim.foreach_rtp(FailingCall()):(<class 'NotImplementedError'>, NotImplementedError('call',)) 2797vim.foreach_rtp(int, 2):(<class 'TypeError'>, TypeError('foreach_rtp() takes exactly one argument (2 given)',)) 2798> import 2799import xxx_no_such_module_xxx:(<class 'ImportError'>, ImportError('No module named xxx_no_such_module_xxx',)) 2800import failing_import:(<class 'ImportError'>, ImportError()) 2801import failing:(<class 'NotImplementedError'>, NotImplementedError()) 2802> Options 2803>> OptionsItem 2804vim.options["abcQ"]:(<class 'KeyError'>, KeyError('abcQ',)) 2805vim.options[""]:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2806>>> Testing StringToChars using vim.options[%s] 2807vim.options[1]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2808vim.options[b"\0"]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2809vim.options["\0"]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2810<<< Finished 2811>> OptionsContains 2812>>> Testing StringToChars using %s in vim.options 28131 in vim.options:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2814b"\0" in vim.options:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2815"\0" in vim.options:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2816<<< Finished 2817> Dictionary 2818>> DictionaryConstructor 2819vim.Dictionary("abcI"):(<class 'ValueError'>, ValueError('expected sequence element of size 2, but got sequence of size 1',)) 2820>> DictionarySetattr 2821del d.locked:(<class 'AttributeError'>, AttributeError('cannot delete vim.Dictionary attributes',)) 2822d.locked = FailingTrue():(<class 'NotImplementedError'>, NotImplementedError('bool',)) 2823vim.vvars.locked = False:(<class 'TypeError'>, TypeError('cannot modify fixed dictionary',)) 2824d.scope = True:(<class 'AttributeError'>, AttributeError('cannot set attribute scope',)) 2825d.xxx = True:(<class 'AttributeError'>, AttributeError('cannot set attribute xxx',)) 2826>> _DictionaryItem 2827d.get("a", 2, 3):(<class 'TypeError'>, TypeError('function takes at most 2 arguments (3 given)',)) 2828>>> Testing StringToChars using d.get(%s) 2829d.get(1):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2830d.get(b"\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2831d.get("\0"):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2832<<< Finished 2833d.pop("a"):(<class 'KeyError'>, KeyError('a',)) 2834dl.pop("a"):(<class 'vim.error'>, error('dictionary is locked',)) 2835>> DictionaryContains 2836"" in d:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 28370 in d:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2838>> DictionaryIterNext 2839for i in ned: ned["a"] = 1:(<class 'RuntimeError'>, RuntimeError('hashtab changed during iteration',)) 2840>> DictionaryAssItem 2841dl["b"] = 1:(<class 'vim.error'>, error('dictionary is locked',)) 2842>>> Testing StringToChars using d[%s] = 1 2843d[1] = 1:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2844d[b"\0"] = 1:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2845d["\0"] = 1:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2846<<< Finished 2847>>> Testing StringToChars using d["a"] = {%s : 1} 2848d["a"] = {1 : 1}:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2849d["a"] = {b"\0" : 1}:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2850d["a"] = {"\0" : 1}:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2851<<< Finished 2852>>> Testing StringToChars using d["a"] = {"abcF" : {%s : 1}} 2853d["a"] = {"abcF" : {1 : 1}}:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2854d["a"] = {"abcF" : {b"\0" : 1}}:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2855d["a"] = {"abcF" : {"\0" : 1}}:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2856<<< Finished 2857>>> Testing StringToChars using d["a"] = {"abcF" : Mapping({%s : 1})} 2858d["a"] = {"abcF" : Mapping({1 : 1})}:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2859d["a"] = {"abcF" : Mapping({b"\0" : 1})}:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2860d["a"] = {"abcF" : Mapping({"\0" : 1})}:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2861<<< Finished 2862>>> Testing *Iter* using d["a"] = {"abcF" : %s} 2863d["a"] = {"abcF" : FailingIter()}:(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 2864d["a"] = {"abcF" : FailingIterNext()}:(<class 'NotImplementedError'>, NotImplementedError('next',)) 2865<<< Finished 2866>>> Testing ConvertFromPyObject using d["a"] = {"abcF" : %s} 2867d["a"] = {"abcF" : None}:NOT FAILED 2868d["a"] = {"abcF" : {b"": 1}}:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2869d["a"] = {"abcF" : {"": 1}}:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2870d["a"] = {"abcF" : FailingMapping()}:(<class 'NotImplementedError'>, NotImplementedError('keys',)) 2871d["a"] = {"abcF" : FailingMappingKey()}:(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 2872d["a"] = {"abcF" : FailingNumber()}:(<class 'NotImplementedError'>, NotImplementedError('int',)) 2873<<< Finished 2874>>> Testing StringToChars using d["a"] = Mapping({%s : 1}) 2875d["a"] = Mapping({1 : 1}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2876d["a"] = Mapping({b"\0" : 1}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2877d["a"] = Mapping({"\0" : 1}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2878<<< Finished 2879>>> Testing StringToChars using d["a"] = Mapping({"abcG" : {%s : 1}}) 2880d["a"] = Mapping({"abcG" : {1 : 1}}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2881d["a"] = Mapping({"abcG" : {b"\0" : 1}}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2882d["a"] = Mapping({"abcG" : {"\0" : 1}}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2883<<< Finished 2884>>> Testing StringToChars using d["a"] = Mapping({"abcG" : Mapping({%s : 1})}) 2885d["a"] = Mapping({"abcG" : Mapping({1 : 1})}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2886d["a"] = Mapping({"abcG" : Mapping({b"\0" : 1})}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2887d["a"] = Mapping({"abcG" : Mapping({"\0" : 1})}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2888<<< Finished 2889>>> Testing *Iter* using d["a"] = Mapping({"abcG" : %s}) 2890d["a"] = Mapping({"abcG" : FailingIter()}):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 2891d["a"] = Mapping({"abcG" : FailingIterNext()}):(<class 'NotImplementedError'>, NotImplementedError('next',)) 2892<<< Finished 2893>>> Testing ConvertFromPyObject using d["a"] = Mapping({"abcG" : %s}) 2894d["a"] = Mapping({"abcG" : None}):NOT FAILED 2895d["a"] = Mapping({"abcG" : {b"": 1}}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2896d["a"] = Mapping({"abcG" : {"": 1}}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2897d["a"] = Mapping({"abcG" : FailingMapping()}):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 2898d["a"] = Mapping({"abcG" : FailingMappingKey()}):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 2899d["a"] = Mapping({"abcG" : FailingNumber()}):(<class 'NotImplementedError'>, NotImplementedError('int',)) 2900<<< Finished 2901>>> Testing *Iter* using d["a"] = %s 2902d["a"] = FailingIter():(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 2903d["a"] = FailingIterNext():(<class 'NotImplementedError'>, NotImplementedError('next',)) 2904<<< Finished 2905>>> Testing ConvertFromPyObject using d["a"] = %s 2906d["a"] = None:NOT FAILED 2907d["a"] = {b"": 1}:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2908d["a"] = {"": 1}:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2909d["a"] = FailingMapping():(<class 'NotImplementedError'>, NotImplementedError('keys',)) 2910d["a"] = FailingMappingKey():(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 2911d["a"] = FailingNumber():(<class 'NotImplementedError'>, NotImplementedError('int',)) 2912<<< Finished 2913>> DictionaryUpdate 2914>>> kwargs 2915>>> iter 2916d.update(FailingMapping()):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 2917d.update([FailingIterNext()]):(<class 'NotImplementedError'>, NotImplementedError('next',)) 2918d.update([FailingIterNextN(1)]):(<class 'NotImplementedError'>, NotImplementedError('next N',)) 2919>>> Testing *Iter* using d.update(%s) 2920d.update(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError('iter',)) 2921d.update(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError('next',)) 2922<<< Finished 2923>>> Testing StringToChars using d.update({%s : 1}) 2924d.update({1 : 1}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2925d.update({b"\0" : 1}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2926d.update({"\0" : 1}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2927<<< Finished 2928>>> Testing StringToChars using d.update({"abcF" : {%s : 1}}) 2929d.update({"abcF" : {1 : 1}}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2930d.update({"abcF" : {b"\0" : 1}}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2931d.update({"abcF" : {"\0" : 1}}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2932<<< Finished 2933>>> Testing StringToChars using d.update({"abcF" : Mapping({%s : 1})}) 2934d.update({"abcF" : Mapping({1 : 1})}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2935d.update({"abcF" : Mapping({b"\0" : 1})}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2936d.update({"abcF" : Mapping({"\0" : 1})}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2937<<< Finished 2938>>> Testing *Iter* using d.update({"abcF" : %s}) 2939d.update({"abcF" : FailingIter()}):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 2940d.update({"abcF" : FailingIterNext()}):(<class 'NotImplementedError'>, NotImplementedError('next',)) 2941<<< Finished 2942>>> Testing ConvertFromPyObject using d.update({"abcF" : %s}) 2943d.update({"abcF" : None}):NOT FAILED 2944d.update({"abcF" : {b"": 1}}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2945d.update({"abcF" : {"": 1}}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2946d.update({"abcF" : FailingMapping()}):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 2947d.update({"abcF" : FailingMappingKey()}):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 2948d.update({"abcF" : FailingNumber()}):(<class 'NotImplementedError'>, NotImplementedError('int',)) 2949<<< Finished 2950>>> Testing StringToChars using d.update(Mapping({%s : 1})) 2951d.update(Mapping({1 : 1})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2952d.update(Mapping({b"\0" : 1})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2953d.update(Mapping({"\0" : 1})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2954<<< Finished 2955>>> Testing StringToChars using d.update(Mapping({"abcG" : {%s : 1}})) 2956d.update(Mapping({"abcG" : {1 : 1}})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2957d.update(Mapping({"abcG" : {b"\0" : 1}})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2958d.update(Mapping({"abcG" : {"\0" : 1}})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2959<<< Finished 2960>>> Testing StringToChars using d.update(Mapping({"abcG" : Mapping({%s : 1})})) 2961d.update(Mapping({"abcG" : Mapping({1 : 1})})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2962d.update(Mapping({"abcG" : Mapping({b"\0" : 1})})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2963d.update(Mapping({"abcG" : Mapping({"\0" : 1})})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2964<<< Finished 2965>>> Testing *Iter* using d.update(Mapping({"abcG" : %s})) 2966d.update(Mapping({"abcG" : FailingIter()})):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 2967d.update(Mapping({"abcG" : FailingIterNext()})):(<class 'NotImplementedError'>, NotImplementedError('next',)) 2968<<< Finished 2969>>> Testing ConvertFromPyObject using d.update(Mapping({"abcG" : %s})) 2970d.update(Mapping({"abcG" : None})):NOT FAILED 2971d.update(Mapping({"abcG" : {b"": 1}})):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2972d.update(Mapping({"abcG" : {"": 1}})):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2973d.update(Mapping({"abcG" : FailingMapping()})):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 2974d.update(Mapping({"abcG" : FailingMappingKey()})):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 2975d.update(Mapping({"abcG" : FailingNumber()})):(<class 'NotImplementedError'>, NotImplementedError('int',)) 2976<<< Finished 2977>>> Testing *Iter* using d.update(%s) 2978d.update(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError('iter',)) 2979d.update(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError('next',)) 2980<<< Finished 2981>>> Testing ConvertFromPyObject using d.update(%s) 2982d.update(None):(<class 'TypeError'>, TypeError("'NoneType' object is not iterable",)) 2983d.update({b"": 1}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2984d.update({"": 1}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 2985d.update(FailingMapping()):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 2986d.update(FailingMappingKey()):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 2987d.update(FailingNumber()):(<class 'TypeError'>, TypeError("'FailingNumber' object is not iterable",)) 2988<<< Finished 2989>>> Testing StringToChars using d.update(((%s, 0),)) 2990d.update(((1, 0),)):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2991d.update(((b"\0", 0),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2992d.update((("\0", 0),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2993<<< Finished 2994>>> Testing StringToChars using d.update((("a", {%s : 1}),)) 2995d.update((("a", {1 : 1}),)):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 2996d.update((("a", {b"\0" : 1}),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2997d.update((("a", {"\0" : 1}),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 2998<<< Finished 2999>>> Testing StringToChars using d.update((("a", {"abcF" : {%s : 1}}),)) 3000d.update((("a", {"abcF" : {1 : 1}}),)):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3001d.update((("a", {"abcF" : {b"\0" : 1}}),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3002d.update((("a", {"abcF" : {"\0" : 1}}),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3003<<< Finished 3004>>> Testing StringToChars using d.update((("a", {"abcF" : Mapping({%s : 1})}),)) 3005d.update((("a", {"abcF" : Mapping({1 : 1})}),)):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3006d.update((("a", {"abcF" : Mapping({b"\0" : 1})}),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3007d.update((("a", {"abcF" : Mapping({"\0" : 1})}),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3008<<< Finished 3009>>> Testing *Iter* using d.update((("a", {"abcF" : %s}),)) 3010d.update((("a", {"abcF" : FailingIter()}),)):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3011d.update((("a", {"abcF" : FailingIterNext()}),)):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3012<<< Finished 3013>>> Testing ConvertFromPyObject using d.update((("a", {"abcF" : %s}),)) 3014d.update((("a", {"abcF" : None}),)):(<class 'vim.error'>, error("failed to add key 'a' to dictionary",)) 3015d.update((("a", {"abcF" : {b"": 1}}),)):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3016d.update((("a", {"abcF" : {"": 1}}),)):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3017d.update((("a", {"abcF" : FailingMapping()}),)):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3018d.update((("a", {"abcF" : FailingMappingKey()}),)):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3019d.update((("a", {"abcF" : FailingNumber()}),)):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3020<<< Finished 3021>>> Testing StringToChars using d.update((("a", Mapping({%s : 1})),)) 3022d.update((("a", Mapping({1 : 1})),)):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3023d.update((("a", Mapping({b"\0" : 1})),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3024d.update((("a", Mapping({"\0" : 1})),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3025<<< Finished 3026>>> Testing StringToChars using d.update((("a", Mapping({"abcG" : {%s : 1}})),)) 3027d.update((("a", Mapping({"abcG" : {1 : 1}})),)):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3028d.update((("a", Mapping({"abcG" : {b"\0" : 1}})),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3029d.update((("a", Mapping({"abcG" : {"\0" : 1}})),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3030<<< Finished 3031>>> Testing StringToChars using d.update((("a", Mapping({"abcG" : Mapping({%s : 1})})),)) 3032d.update((("a", Mapping({"abcG" : Mapping({1 : 1})})),)):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3033d.update((("a", Mapping({"abcG" : Mapping({b"\0" : 1})})),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3034d.update((("a", Mapping({"abcG" : Mapping({"\0" : 1})})),)):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3035<<< Finished 3036>>> Testing *Iter* using d.update((("a", Mapping({"abcG" : %s})),)) 3037d.update((("a", Mapping({"abcG" : FailingIter()})),)):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3038d.update((("a", Mapping({"abcG" : FailingIterNext()})),)):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3039<<< Finished 3040>>> Testing ConvertFromPyObject using d.update((("a", Mapping({"abcG" : %s})),)) 3041d.update((("a", Mapping({"abcG" : None})),)):(<class 'vim.error'>, error("failed to add key 'a' to dictionary",)) 3042d.update((("a", Mapping({"abcG" : {b"": 1}})),)):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3043d.update((("a", Mapping({"abcG" : {"": 1}})),)):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3044d.update((("a", Mapping({"abcG" : FailingMapping()})),)):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3045d.update((("a", Mapping({"abcG" : FailingMappingKey()})),)):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3046d.update((("a", Mapping({"abcG" : FailingNumber()})),)):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3047<<< Finished 3048>>> Testing *Iter* using d.update((("a", %s),)) 3049d.update((("a", FailingIter()),)):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3050d.update((("a", FailingIterNext()),)):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3051<<< Finished 3052>>> Testing ConvertFromPyObject using d.update((("a", %s),)) 3053d.update((("a", None),)):(<class 'vim.error'>, error("failed to add key 'a' to dictionary",)) 3054d.update((("a", {b"": 1}),)):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3055d.update((("a", {"": 1}),)):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3056d.update((("a", FailingMapping()),)):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3057d.update((("a", FailingMappingKey()),)):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3058d.update((("a", FailingNumber()),)):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3059<<< Finished 3060>> DictionaryPopItem 3061d.popitem(1, 2):(<class 'TypeError'>, TypeError('popitem() takes no arguments (2 given)',)) 3062>> DictionaryHasKey 3063d.has_key():(<class 'TypeError'>, TypeError('has_key() takes exactly one argument (0 given)',)) 3064> List 3065>> ListConstructor 3066vim.List(1, 2):(<class 'TypeError'>, TypeError('function takes at most 1 argument (2 given)',)) 3067vim.List(a=1):(<class 'TypeError'>, TypeError('list constructor does not accept keyword arguments',)) 3068>>> Testing *Iter* using vim.List(%s) 3069vim.List(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError('iter',)) 3070vim.List(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3071<<< Finished 3072>>> Testing StringToChars using vim.List([{%s : 1}]) 3073vim.List([{1 : 1}]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3074vim.List([{b"\0" : 1}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3075vim.List([{"\0" : 1}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3076<<< Finished 3077>>> Testing StringToChars using vim.List([{"abcF" : {%s : 1}}]) 3078vim.List([{"abcF" : {1 : 1}}]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3079vim.List([{"abcF" : {b"\0" : 1}}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3080vim.List([{"abcF" : {"\0" : 1}}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3081<<< Finished 3082>>> Testing StringToChars using vim.List([{"abcF" : Mapping({%s : 1})}]) 3083vim.List([{"abcF" : Mapping({1 : 1})}]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3084vim.List([{"abcF" : Mapping({b"\0" : 1})}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3085vim.List([{"abcF" : Mapping({"\0" : 1})}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3086<<< Finished 3087>>> Testing *Iter* using vim.List([{"abcF" : %s}]) 3088vim.List([{"abcF" : FailingIter()}]):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3089vim.List([{"abcF" : FailingIterNext()}]):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3090<<< Finished 3091>>> Testing ConvertFromPyObject using vim.List([{"abcF" : %s}]) 3092vim.List([{"abcF" : None}]):NOT FAILED 3093vim.List([{"abcF" : {b"": 1}}]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3094vim.List([{"abcF" : {"": 1}}]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3095vim.List([{"abcF" : FailingMapping()}]):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3096vim.List([{"abcF" : FailingMappingKey()}]):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3097vim.List([{"abcF" : FailingNumber()}]):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3098<<< Finished 3099>>> Testing StringToChars using vim.List([Mapping({%s : 1})]) 3100vim.List([Mapping({1 : 1})]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3101vim.List([Mapping({b"\0" : 1})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3102vim.List([Mapping({"\0" : 1})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3103<<< Finished 3104>>> Testing StringToChars using vim.List([Mapping({"abcG" : {%s : 1}})]) 3105vim.List([Mapping({"abcG" : {1 : 1}})]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3106vim.List([Mapping({"abcG" : {b"\0" : 1}})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3107vim.List([Mapping({"abcG" : {"\0" : 1}})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3108<<< Finished 3109>>> Testing StringToChars using vim.List([Mapping({"abcG" : Mapping({%s : 1})})]) 3110vim.List([Mapping({"abcG" : Mapping({1 : 1})})]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3111vim.List([Mapping({"abcG" : Mapping({b"\0" : 1})})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3112vim.List([Mapping({"abcG" : Mapping({"\0" : 1})})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3113<<< Finished 3114>>> Testing *Iter* using vim.List([Mapping({"abcG" : %s})]) 3115vim.List([Mapping({"abcG" : FailingIter()})]):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3116vim.List([Mapping({"abcG" : FailingIterNext()})]):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3117<<< Finished 3118>>> Testing ConvertFromPyObject using vim.List([Mapping({"abcG" : %s})]) 3119vim.List([Mapping({"abcG" : None})]):NOT FAILED 3120vim.List([Mapping({"abcG" : {b"": 1}})]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3121vim.List([Mapping({"abcG" : {"": 1}})]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3122vim.List([Mapping({"abcG" : FailingMapping()})]):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3123vim.List([Mapping({"abcG" : FailingMappingKey()})]):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3124vim.List([Mapping({"abcG" : FailingNumber()})]):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3125<<< Finished 3126>>> Testing *Iter* using vim.List([%s]) 3127vim.List([FailingIter()]):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3128vim.List([FailingIterNext()]):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3129<<< Finished 3130>>> Testing ConvertFromPyObject using vim.List([%s]) 3131vim.List([None]):NOT FAILED 3132vim.List([{b"": 1}]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3133vim.List([{"": 1}]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3134vim.List([FailingMapping()]):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3135vim.List([FailingMappingKey()]):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3136vim.List([FailingNumber()]):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3137<<< Finished 3138>> ListItem 3139l[1000]:(<class 'IndexError'>, IndexError('list index out of range',)) 3140>> ListAssItem 3141ll[1] = 2:(<class 'vim.error'>, error('list is locked',)) 3142l[1000] = 3:(<class 'IndexError'>, IndexError('list index out of range',)) 3143>> ListAssSlice 3144ll[1:100] = "abcJ":(<class 'vim.error'>, error('list is locked',)) 3145>>> Testing *Iter* using l[:] = %s 3146l[:] = FailingIter():(<class 'NotImplementedError'>, NotImplementedError('iter',)) 3147l[:] = FailingIterNext():(<class 'NotImplementedError'>, NotImplementedError('next',)) 3148<<< Finished 3149nel[1:10:2] = "abcK":(<class 'ValueError'>, ValueError('attempt to assign sequence of size greater than 2 to extended slice',)) 3150(b'a', b'b', b'c', b'O') 3151nel[1:10:2] = "a":(<class 'ValueError'>, ValueError('attempt to assign sequence of size 1 to extended slice of size 2',)) 3152(b'a', b'b', b'c', b'O') 3153nel[1:1:-1] = "a":(<class 'ValueError'>, ValueError('attempt to assign sequence of size greater than 0 to extended slice',)) 3154(b'a', b'b', b'c', b'O') 3155nel[:] = FailingIterNextN(2):(<class 'NotImplementedError'>, NotImplementedError('next N',)) 3156(b'a', b'b', b'c', b'O') 3157>>> Testing StringToChars using l[:] = [{%s : 1}] 3158l[:] = [{1 : 1}]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3159l[:] = [{b"\0" : 1}]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3160l[:] = [{"\0" : 1}]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3161<<< Finished 3162>>> Testing StringToChars using l[:] = [{"abcF" : {%s : 1}}] 3163l[:] = [{"abcF" : {1 : 1}}]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3164l[:] = [{"abcF" : {b"\0" : 1}}]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3165l[:] = [{"abcF" : {"\0" : 1}}]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3166<<< Finished 3167>>> Testing StringToChars using l[:] = [{"abcF" : Mapping({%s : 1})}] 3168l[:] = [{"abcF" : Mapping({1 : 1})}]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3169l[:] = [{"abcF" : Mapping({b"\0" : 1})}]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3170l[:] = [{"abcF" : Mapping({"\0" : 1})}]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3171<<< Finished 3172>>> Testing *Iter* using l[:] = [{"abcF" : %s}] 3173l[:] = [{"abcF" : FailingIter()}]:(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3174l[:] = [{"abcF" : FailingIterNext()}]:(<class 'NotImplementedError'>, NotImplementedError('next',)) 3175<<< Finished 3176>>> Testing ConvertFromPyObject using l[:] = [{"abcF" : %s}] 3177l[:] = [{"abcF" : None}]:NOT FAILED 3178l[:] = [{"abcF" : {b"": 1}}]:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3179l[:] = [{"abcF" : {"": 1}}]:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3180l[:] = [{"abcF" : FailingMapping()}]:(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3181l[:] = [{"abcF" : FailingMappingKey()}]:(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3182l[:] = [{"abcF" : FailingNumber()}]:(<class 'NotImplementedError'>, NotImplementedError('int',)) 3183<<< Finished 3184>>> Testing StringToChars using l[:] = [Mapping({%s : 1})] 3185l[:] = [Mapping({1 : 1})]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3186l[:] = [Mapping({b"\0" : 1})]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3187l[:] = [Mapping({"\0" : 1})]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3188<<< Finished 3189>>> Testing StringToChars using l[:] = [Mapping({"abcG" : {%s : 1}})] 3190l[:] = [Mapping({"abcG" : {1 : 1}})]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3191l[:] = [Mapping({"abcG" : {b"\0" : 1}})]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3192l[:] = [Mapping({"abcG" : {"\0" : 1}})]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3193<<< Finished 3194>>> Testing StringToChars using l[:] = [Mapping({"abcG" : Mapping({%s : 1})})] 3195l[:] = [Mapping({"abcG" : Mapping({1 : 1})})]:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3196l[:] = [Mapping({"abcG" : Mapping({b"\0" : 1})})]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3197l[:] = [Mapping({"abcG" : Mapping({"\0" : 1})})]:(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3198<<< Finished 3199>>> Testing *Iter* using l[:] = [Mapping({"abcG" : %s})] 3200l[:] = [Mapping({"abcG" : FailingIter()})]:(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3201l[:] = [Mapping({"abcG" : FailingIterNext()})]:(<class 'NotImplementedError'>, NotImplementedError('next',)) 3202<<< Finished 3203>>> Testing ConvertFromPyObject using l[:] = [Mapping({"abcG" : %s})] 3204l[:] = [Mapping({"abcG" : None})]:NOT FAILED 3205l[:] = [Mapping({"abcG" : {b"": 1}})]:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3206l[:] = [Mapping({"abcG" : {"": 1}})]:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3207l[:] = [Mapping({"abcG" : FailingMapping()})]:(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3208l[:] = [Mapping({"abcG" : FailingMappingKey()})]:(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3209l[:] = [Mapping({"abcG" : FailingNumber()})]:(<class 'NotImplementedError'>, NotImplementedError('int',)) 3210<<< Finished 3211>>> Testing *Iter* using l[:] = [%s] 3212l[:] = [FailingIter()]:(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3213l[:] = [FailingIterNext()]:(<class 'NotImplementedError'>, NotImplementedError('next',)) 3214<<< Finished 3215>>> Testing ConvertFromPyObject using l[:] = [%s] 3216l[:] = [None]:NOT FAILED 3217l[:] = [{b"": 1}]:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3218l[:] = [{"": 1}]:(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3219l[:] = [FailingMapping()]:(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3220l[:] = [FailingMappingKey()]:(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3221l[:] = [FailingNumber()]:(<class 'NotImplementedError'>, NotImplementedError('int',)) 3222<<< Finished 3223>> ListConcatInPlace 3224>>> Testing *Iter* using l.extend(%s) 3225l.extend(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError('iter',)) 3226l.extend(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3227<<< Finished 3228>>> Testing StringToChars using l.extend([{%s : 1}]) 3229l.extend([{1 : 1}]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3230l.extend([{b"\0" : 1}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3231l.extend([{"\0" : 1}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3232<<< Finished 3233>>> Testing StringToChars using l.extend([{"abcF" : {%s : 1}}]) 3234l.extend([{"abcF" : {1 : 1}}]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3235l.extend([{"abcF" : {b"\0" : 1}}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3236l.extend([{"abcF" : {"\0" : 1}}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3237<<< Finished 3238>>> Testing StringToChars using l.extend([{"abcF" : Mapping({%s : 1})}]) 3239l.extend([{"abcF" : Mapping({1 : 1})}]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3240l.extend([{"abcF" : Mapping({b"\0" : 1})}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3241l.extend([{"abcF" : Mapping({"\0" : 1})}]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3242<<< Finished 3243>>> Testing *Iter* using l.extend([{"abcF" : %s}]) 3244l.extend([{"abcF" : FailingIter()}]):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3245l.extend([{"abcF" : FailingIterNext()}]):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3246<<< Finished 3247>>> Testing ConvertFromPyObject using l.extend([{"abcF" : %s}]) 3248l.extend([{"abcF" : None}]):NOT FAILED 3249l.extend([{"abcF" : {b"": 1}}]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3250l.extend([{"abcF" : {"": 1}}]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3251l.extend([{"abcF" : FailingMapping()}]):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3252l.extend([{"abcF" : FailingMappingKey()}]):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3253l.extend([{"abcF" : FailingNumber()}]):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3254<<< Finished 3255>>> Testing StringToChars using l.extend([Mapping({%s : 1})]) 3256l.extend([Mapping({1 : 1})]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3257l.extend([Mapping({b"\0" : 1})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3258l.extend([Mapping({"\0" : 1})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3259<<< Finished 3260>>> Testing StringToChars using l.extend([Mapping({"abcG" : {%s : 1}})]) 3261l.extend([Mapping({"abcG" : {1 : 1}})]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3262l.extend([Mapping({"abcG" : {b"\0" : 1}})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3263l.extend([Mapping({"abcG" : {"\0" : 1}})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3264<<< Finished 3265>>> Testing StringToChars using l.extend([Mapping({"abcG" : Mapping({%s : 1})})]) 3266l.extend([Mapping({"abcG" : Mapping({1 : 1})})]):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3267l.extend([Mapping({"abcG" : Mapping({b"\0" : 1})})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3268l.extend([Mapping({"abcG" : Mapping({"\0" : 1})})]):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3269<<< Finished 3270>>> Testing *Iter* using l.extend([Mapping({"abcG" : %s})]) 3271l.extend([Mapping({"abcG" : FailingIter()})]):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3272l.extend([Mapping({"abcG" : FailingIterNext()})]):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3273<<< Finished 3274>>> Testing ConvertFromPyObject using l.extend([Mapping({"abcG" : %s})]) 3275l.extend([Mapping({"abcG" : None})]):NOT FAILED 3276l.extend([Mapping({"abcG" : {b"": 1}})]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3277l.extend([Mapping({"abcG" : {"": 1}})]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3278l.extend([Mapping({"abcG" : FailingMapping()})]):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3279l.extend([Mapping({"abcG" : FailingMappingKey()})]):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3280l.extend([Mapping({"abcG" : FailingNumber()})]):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3281<<< Finished 3282>>> Testing *Iter* using l.extend([%s]) 3283l.extend([FailingIter()]):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3284l.extend([FailingIterNext()]):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3285<<< Finished 3286>>> Testing ConvertFromPyObject using l.extend([%s]) 3287l.extend([None]):NOT FAILED 3288l.extend([{b"": 1}]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3289l.extend([{"": 1}]):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3290l.extend([FailingMapping()]):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3291l.extend([FailingMappingKey()]):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3292l.extend([FailingNumber()]):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3293<<< Finished 3294>> ListSetattr 3295del l.locked:(<class 'AttributeError'>, AttributeError('cannot delete vim.List attributes',)) 3296l.locked = FailingTrue():(<class 'NotImplementedError'>, NotImplementedError('bool',)) 3297l.xxx = True:(<class 'AttributeError'>, AttributeError('cannot set attribute xxx',)) 3298> Function 3299>> FunctionConstructor 3300>>> FunctionConstructor 3301vim.Function("123"):(<class 'ValueError'>, ValueError('unnamed function 123 does not exist',)) 3302vim.Function("xxx_non_existent_function_xxx"):(<class 'ValueError'>, ValueError('function xxx_non_existent_function_xxx does not exist',)) 3303vim.Function("xxx#non#existent#function#xxx"):NOT FAILED 3304vim.Function("xxx_non_existent_function_xxx2", args=[]):(<class 'ValueError'>, ValueError('function xxx_non_existent_function_xxx2 does not exist',)) 3305vim.Function("xxx_non_existent_function_xxx3", self={}):(<class 'ValueError'>, ValueError('function xxx_non_existent_function_xxx3 does not exist',)) 3306vim.Function("xxx_non_existent_function_xxx4", args=[], self={}):(<class 'ValueError'>, ValueError('function xxx_non_existent_function_xxx4 does not exist',)) 3307>>> FunctionNew 3308vim.Function("tr", self="abcFuncSelf"):(<class 'AttributeError'>, AttributeError('keys',)) 3309vim.Function("tr", args=427423):(<class 'TypeError'>, TypeError('unable to convert int to a Vim list',)) 3310vim.Function("tr", self="abcFuncSelf2", args="abcFuncArgs2"):(<class 'AttributeError'>, AttributeError('keys',)) 3311vim.Function(self="abcFuncSelf2", args="abcFuncArgs2"):(<class 'AttributeError'>, AttributeError('keys',)) 3312vim.Function("tr", "", self="abcFuncSelf2", args="abcFuncArgs2"):(<class 'AttributeError'>, AttributeError('keys',)) 3313vim.Function("tr", ""):(<class 'TypeError'>, TypeError('function takes exactly 1 argument (2 given)',)) 3314>> FunctionCall 3315>>> Testing StringToChars using f({%s : 1}) 3316f({1 : 1}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3317f({b"\0" : 1}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3318f({"\0" : 1}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3319<<< Finished 3320>>> Testing StringToChars using f({"abcF" : {%s : 1}}) 3321f({"abcF" : {1 : 1}}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3322f({"abcF" : {b"\0" : 1}}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3323f({"abcF" : {"\0" : 1}}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3324<<< Finished 3325>>> Testing StringToChars using f({"abcF" : Mapping({%s : 1})}) 3326f({"abcF" : Mapping({1 : 1})}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3327f({"abcF" : Mapping({b"\0" : 1})}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3328f({"abcF" : Mapping({"\0" : 1})}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3329<<< Finished 3330>>> Testing *Iter* using f({"abcF" : %s}) 3331f({"abcF" : FailingIter()}):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3332f({"abcF" : FailingIterNext()}):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3333<<< Finished 3334>>> Testing ConvertFromPyObject using f({"abcF" : %s}) 3335f({"abcF" : None}):NOT FAILED 3336f({"abcF" : {b"": 1}}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3337f({"abcF" : {"": 1}}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3338f({"abcF" : FailingMapping()}):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3339f({"abcF" : FailingMappingKey()}):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3340f({"abcF" : FailingNumber()}):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3341<<< Finished 3342>>> Testing StringToChars using f(Mapping({%s : 1})) 3343f(Mapping({1 : 1})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3344f(Mapping({b"\0" : 1})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3345f(Mapping({"\0" : 1})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3346<<< Finished 3347>>> Testing StringToChars using f(Mapping({"abcG" : {%s : 1}})) 3348f(Mapping({"abcG" : {1 : 1}})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3349f(Mapping({"abcG" : {b"\0" : 1}})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3350f(Mapping({"abcG" : {"\0" : 1}})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3351<<< Finished 3352>>> Testing StringToChars using f(Mapping({"abcG" : Mapping({%s : 1})})) 3353f(Mapping({"abcG" : Mapping({1 : 1})})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3354f(Mapping({"abcG" : Mapping({b"\0" : 1})})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3355f(Mapping({"abcG" : Mapping({"\0" : 1})})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3356<<< Finished 3357>>> Testing *Iter* using f(Mapping({"abcG" : %s})) 3358f(Mapping({"abcG" : FailingIter()})):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3359f(Mapping({"abcG" : FailingIterNext()})):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3360<<< Finished 3361>>> Testing ConvertFromPyObject using f(Mapping({"abcG" : %s})) 3362f(Mapping({"abcG" : None})):NOT FAILED 3363f(Mapping({"abcG" : {b"": 1}})):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3364f(Mapping({"abcG" : {"": 1}})):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3365f(Mapping({"abcG" : FailingMapping()})):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3366f(Mapping({"abcG" : FailingMappingKey()})):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3367f(Mapping({"abcG" : FailingNumber()})):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3368<<< Finished 3369>>> Testing *Iter* using f(%s) 3370f(FailingIter()):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3371f(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3372<<< Finished 3373>>> Testing ConvertFromPyObject using f(%s) 3374f(None):NOT FAILED 3375f({b"": 1}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3376f({"": 1}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3377f(FailingMapping()):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3378f(FailingMappingKey()):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3379f(FailingNumber()):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3380<<< Finished 3381>>> Testing StringToChars using fd(self={%s : 1}) 3382fd(self={1 : 1}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3383fd(self={b"\0" : 1}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3384fd(self={"\0" : 1}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3385<<< Finished 3386>>> Testing StringToChars using fd(self={"abcF" : {%s : 1}}) 3387fd(self={"abcF" : {1 : 1}}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3388fd(self={"abcF" : {b"\0" : 1}}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3389fd(self={"abcF" : {"\0" : 1}}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3390<<< Finished 3391>>> Testing StringToChars using fd(self={"abcF" : Mapping({%s : 1})}) 3392fd(self={"abcF" : Mapping({1 : 1})}):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3393fd(self={"abcF" : Mapping({b"\0" : 1})}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3394fd(self={"abcF" : Mapping({"\0" : 1})}):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3395<<< Finished 3396>>> Testing *Iter* using fd(self={"abcF" : %s}) 3397fd(self={"abcF" : FailingIter()}):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3398fd(self={"abcF" : FailingIterNext()}):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3399<<< Finished 3400>>> Testing ConvertFromPyObject using fd(self={"abcF" : %s}) 3401fd(self={"abcF" : None}):NOT FAILED 3402fd(self={"abcF" : {b"": 1}}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3403fd(self={"abcF" : {"": 1}}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3404fd(self={"abcF" : FailingMapping()}):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3405fd(self={"abcF" : FailingMappingKey()}):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3406fd(self={"abcF" : FailingNumber()}):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3407<<< Finished 3408>>> Testing StringToChars using fd(self=Mapping({%s : 1})) 3409fd(self=Mapping({1 : 1})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3410fd(self=Mapping({b"\0" : 1})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3411fd(self=Mapping({"\0" : 1})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3412<<< Finished 3413>>> Testing StringToChars using fd(self=Mapping({"abcG" : {%s : 1}})) 3414fd(self=Mapping({"abcG" : {1 : 1}})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3415fd(self=Mapping({"abcG" : {b"\0" : 1}})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3416fd(self=Mapping({"abcG" : {"\0" : 1}})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3417<<< Finished 3418>>> Testing StringToChars using fd(self=Mapping({"abcG" : Mapping({%s : 1})})) 3419fd(self=Mapping({"abcG" : Mapping({1 : 1})})):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3420fd(self=Mapping({"abcG" : Mapping({b"\0" : 1})})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3421fd(self=Mapping({"abcG" : Mapping({"\0" : 1})})):(<class 'TypeError'>, TypeError('expected bytes with no null',)) 3422<<< Finished 3423>>> Testing *Iter* using fd(self=Mapping({"abcG" : %s})) 3424fd(self=Mapping({"abcG" : FailingIter()})):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim structure',)) 3425fd(self=Mapping({"abcG" : FailingIterNext()})):(<class 'NotImplementedError'>, NotImplementedError('next',)) 3426<<< Finished 3427>>> Testing ConvertFromPyObject using fd(self=Mapping({"abcG" : %s})) 3428fd(self=Mapping({"abcG" : None})):NOT FAILED 3429fd(self=Mapping({"abcG" : {b"": 1}})):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3430fd(self=Mapping({"abcG" : {"": 1}})):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3431fd(self=Mapping({"abcG" : FailingMapping()})):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3432fd(self=Mapping({"abcG" : FailingMappingKey()})):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3433fd(self=Mapping({"abcG" : FailingNumber()})):(<class 'NotImplementedError'>, NotImplementedError('int',)) 3434<<< Finished 3435>>> Testing *Iter* using fd(self=%s) 3436fd(self=FailingIter()):(<class 'TypeError'>, TypeError('unable to convert FailingIter to a Vim dictionary',)) 3437fd(self=FailingIterNext()):(<class 'TypeError'>, TypeError('unable to convert FailingIterNext to a Vim dictionary',)) 3438<<< Finished 3439>>> Testing ConvertFromPyObject using fd(self=%s) 3440fd(self=None):(<class 'TypeError'>, TypeError('unable to convert NoneType to a Vim dictionary',)) 3441fd(self={b"": 1}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3442fd(self={"": 1}):(<class 'ValueError'>, ValueError('empty keys are not allowed',)) 3443fd(self=FailingMapping()):(<class 'NotImplementedError'>, NotImplementedError('keys',)) 3444fd(self=FailingMappingKey()):(<class 'NotImplementedError'>, NotImplementedError('getitem:mappingkey',)) 3445fd(self=FailingNumber()):(<class 'TypeError'>, TypeError('unable to convert FailingNumber to a Vim dictionary',)) 3446<<< Finished 3447>>> Testing ConvertFromPyMapping using fd(self=%s) 3448fd(self=[]):(<class 'AttributeError'>, AttributeError('keys',)) 3449<<< Finished 3450> TabPage 3451>> TabPageAttr 3452vim.current.tabpage.xxx:(<class 'AttributeError'>, AttributeError("'vim.tabpage' object has no attribute 'xxx'",)) 3453> TabList 3454>> TabListItem 3455vim.tabpages[1000]:(<class 'IndexError'>, IndexError('no such tab page',)) 3456> Window 3457>> WindowAttr 3458vim.current.window.xxx:(<class 'AttributeError'>, AttributeError("'vim.window' object has no attribute 'xxx'",)) 3459>> WindowSetattr 3460vim.current.window.buffer = 0:(<class 'TypeError'>, TypeError('readonly attribute: buffer',)) 3461vim.current.window.cursor = (100000000, 100000000):(<class 'vim.error'>, error('cursor position outside buffer',)) 3462vim.current.window.cursor = True:(<class 'TypeError'>, TypeError('argument must be 2-item sequence, not bool',)) 3463>>> Testing NumberToLong using vim.current.window.height = %s 3464vim.current.window.height = []:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got list',)) 3465vim.current.window.height = None:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got NoneType',)) 3466vim.current.window.height = -1:(<class 'ValueError'>, ValueError('number must be greater or equal to zero',)) 3467<<< Finished 3468>>> Testing NumberToLong using vim.current.window.width = %s 3469vim.current.window.width = []:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got list',)) 3470vim.current.window.width = None:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got NoneType',)) 3471vim.current.window.width = -1:(<class 'ValueError'>, ValueError('number must be greater or equal to zero',)) 3472<<< Finished 3473vim.current.window.xxxxxx = True:(<class 'AttributeError'>, AttributeError('xxxxxx',)) 3474> WinList 3475>> WinListItem 3476vim.windows[1000]:(<class 'IndexError'>, IndexError('no such window',)) 3477> Buffer 3478>> StringToLine (indirect) 3479vim.current.buffer[0] = "\na":(<class 'vim.error'>, error('string cannot contain newlines',)) 3480vim.current.buffer[0] = b"\na":(<class 'vim.error'>, error('string cannot contain newlines',)) 3481>> SetBufferLine (indirect) 3482vim.current.buffer[0] = True:(<class 'TypeError'>, TypeError('bad argument type for built-in operation',)) 3483>> SetBufferLineList (indirect) 3484vim.current.buffer[:] = True:(<class 'TypeError'>, TypeError('bad argument type for built-in operation',)) 3485vim.current.buffer[:] = ["\na", "bc"]:(<class 'vim.error'>, error('string cannot contain newlines',)) 3486>> InsertBufferLines (indirect) 3487vim.current.buffer.append(None):(<class 'TypeError'>, TypeError('bad argument type for built-in operation',)) 3488vim.current.buffer.append(["\na", "bc"]):(<class 'vim.error'>, error('string cannot contain newlines',)) 3489vim.current.buffer.append("\nbc"):(<class 'vim.error'>, error('string cannot contain newlines',)) 3490>> RBItem 3491vim.current.buffer[100000000]:(<class 'IndexError'>, IndexError('line number out of range',)) 3492>> RBAsItem 3493vim.current.buffer[100000000] = "":(<class 'IndexError'>, IndexError('line number out of range',)) 3494>> BufferAttr 3495vim.current.buffer.xxx:(<class 'AttributeError'>, AttributeError("'vim.buffer' object has no attribute 'xxx'",)) 3496>> BufferSetattr 3497vim.current.buffer.name = True:(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got bool',)) 3498vim.current.buffer.xxx = True:(<class 'AttributeError'>, AttributeError('xxx',)) 3499>> BufferMark 3500vim.current.buffer.mark(0):(<class 'TypeError'>, TypeError('expected bytes() or str() instance, but got int',)) 3501vim.current.buffer.mark("abcM"):(<class 'ValueError'>, ValueError('mark name must be a single character',)) 3502vim.current.buffer.mark("!"):(<class 'vim.error'>, error('invalid mark name',)) 3503>> BufferRange 3504vim.current.buffer.range(1, 2, 3):(<class 'TypeError'>, TypeError('function takes exactly 2 arguments (3 given)',)) 3505> BufMap 3506>> BufMapItem 3507vim.buffers[100000000]:(<class 'KeyError'>, KeyError(100000000,)) 3508>>> Testing NumberToLong using vim.buffers[%s] 3509vim.buffers[[]]:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got list',)) 3510vim.buffers[None]:(<class 'TypeError'>, TypeError('expected int() or something supporting coercing to int(), but got NoneType',)) 3511vim.buffers[-1]:(<class 'ValueError'>, ValueError('number must be greater than zero',)) 3512vim.buffers[0]:(<class 'ValueError'>, ValueError('number must be greater than zero',)) 3513<<< Finished 3514> Current 3515>> CurrentGetattr 3516vim.current.xxx:(<class 'AttributeError'>, AttributeError("'vim.currentdata' object has no attribute 'xxx'",)) 3517>> CurrentSetattr 3518vim.current.line = True:(<class 'TypeError'>, TypeError('bad argument type for built-in operation',)) 3519vim.current.buffer = True:(<class 'TypeError'>, TypeError('expected vim.Buffer object, but got bool',)) 3520vim.current.window = True:(<class 'TypeError'>, TypeError('expected vim.Window object, but got bool',)) 3521vim.current.tabpage = True:(<class 'TypeError'>, TypeError('expected vim.TabPage object, but got bool',)) 3522vim.current.xxx = True:(<class 'AttributeError'>, AttributeError('xxx',)) 3523END 3524 3525let actual = getline ( 2 , '$' ) 3526let n_expected = len ( expected ) 3527let n_actual = len ( actual ) 3528call assert_equal ( n_expected , n_actual , 'number of lines to compare' ) 3529 3530" Compare line by line so the errors are easier to understand. Missing lines 3531" are compared with an empty string. 3532for i in range ( n_expected > n_actual ? n_expected : n_actual ) 3533call assert_equal ( i >= n_expected ? '' : expected [ i ], i >= n_actual ? '' : actual [ i ]) 3534endfor 3535close ! 3536endfunc 3537 3538" Test import 3539func Test_python3_import () 3540throw 'Skipped: TODO: ' 3541new 3542py 3 cb = vim .current .buffer 3543 3544py 3 << trim EOF 3545sys .path.insert(0, os.path.join(os.getcwd(),'python_before' )) 3546sys .path.append(os.path.join(os.getcwd(),'python_after' )) 3547vim .options['rtp'] = os.getcwd().replace(',','\\,' ).replace('\\','\\\\' ) 3548l = [] 3549def callback(path): 3550l .append(os.path.relpath(path)) 3551vim .foreach_rtp(callback) 3552cb .append(repr(l)) 3553del l 3554def callback(path): 3555return os . path . relpath ( path ) 3556cb .append(repr(vim.foreach_rtp(callback))) 3557del callback 3558from module import dir as d 3559from modulex import ddir 3560cb .append(d +',' + ddir) 3561import before 3562cb .append(before.dir) 3563import after 3564cb .append(after.dir) 3565import topmodule as tm 3566import topmodule.submodule as tms 3567import topmodule.submodule.subsubmodule.subsubsubmodule as tmsss 3568cb .append(tm.__file__.replace(os.path.sep,'/' )[-len('modulex/topmodule/__init__.py'):]) 3569cb .append(tms.__file__.replace(os.path.sep,'/' )[-len('modulex/topmodule/submodule/__init__.py'):]) 3570cb .append(tmsss.__file__.replace(os.path.sep,'/' )[-len('modulex/topmodule/submodule/subsubmodule/subsubsubmodule.py'):]) 3571 3572del before 3573del after 3574del d 3575del ddir 3576del tm 3577del tms 3578del tmsss 3579EOF 3580 3581let expected =<< trim END 3582['.'] 3583'.' 35843,xx 3585before 3586after 3587pythonx/topmodule/__init__.py 3588pythonx/topmodule/submodule/__init__.py 3589pythonx/topmodule/submodule/subsubmodule/subsubsubmodule.py 3590END 3591call assert_equal ( expected , getline ( 2 , '$' )) 3592close ! 3593endfunc 3594 3595" Test exceptions 3596func Test_python3_exception () 3597throw 'Skipped: Nvim does not support vim.bindeval()' 3598func Exe ( e ) 3599execute a: e 3600endfunc 3601 3602new 3603py 3 cb = vim .current .buffer 3604 3605py 3 << trim EOF 3606Exe = vim.bindeval('function("Exe")') 3607ee ('vim.command("throw \'abcN\'")') 3608ee ('Exe("throw \'def\'")') 3609ee ('vim.eval("Exe(\'throw \'\'ghi\'\'\')")') 3610ee ('vim.eval("Exe(\'echoerr \'\'jkl\'\'\')")') 3611ee ('vim.eval("Exe(\'xxx_non_existent_command_xxx\')")') 3612ee ('vim.eval("xxx_unknown_function_xxx()")') 3613ee ('vim.bindeval("Exe(\'xxx_non_existent_command_xxx\')")') 3614del Exe 3615EOF 3616delfunction Exe 3617 3618let expected =<< trim END 3619vim.command("throw 'abcN'"):(<class 'vim.error'>, error('abcN',)) 3620Exe("throw 'def'"):(<class 'vim.error'>, error('def',)) 3621vim.eval("Exe('throw ''ghi''')"):(<class 'vim.error'>, error('ghi',)) 3622vim.eval("Exe('echoerr ''jkl''')"):(<class 'vim.error'>, error('Vim(echoerr):jkl',)) 3623vim.eval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)) 3624vim.eval("xxx_unknown_function_xxx()"):(<class 'vim.error'>, error('Vim:E117: Unknown function: xxx_unknown_function_xxx',)) 3625vim.bindeval("Exe('xxx_non_existent_command_xxx')"):(<class 'vim.error'>, error('Vim:E492: Not an editor command: xxx_non_existent_command_xxx',)) 3626END 3627call assert_equal ( expected , getline ( 2 , '$' )) 3628close ! 3629endfunc 3630 3631" Regression: interrupting vim.command propagates to next vim.command 3632func Test_python3_keyboard_interrupt () 3633new 3634py 3 cb = vim .current .buffer 3635py 3 << trim EOF 3636def test_keyboard_interrupt(): 3637try : 3638vim .command('while 1 |endwhile ') 3639except KeyboardInterrupt: 3640cb .append('Caught KeyboardInterrupt') 3641except Exception: 3642cb .append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) 3643else : 3644cb .append('!!!!!!!! No exception') 3645try : 3646vim .command('$ put =\'Running :put\'') 3647except KeyboardInterrupt: 3648cb .append('!!!!!!!! Caught KeyboardInterrupt') 3649except Exception: 3650cb .append('!!!!!!!! Caught exception: ' + emsg(sys.exc_info())) 3651else : 3652cb .append('No exception') 3653EOF 3654 3655debuggreedy 3656call inputsave () 3657call feedkeys ( "s\ns\ns\ns\nq\n" ) 3658redir => output 3659debug silent! py3 test_keyboard_interrupt() 3660redir END 36610 debuggreedy 3662call inputrestore () 3663py 3 del test_keyboard_interrupt 3664 3665let expected =<< trim END 3666!!!!!!!! Caught exception: NvimError:('Keyboard interrupt',) 3667Running :put 3668No exception 3669END 3670call assert_equal ( expected , getline ( 2 , '$' )) 3671call assert_equal ( '' , output ) 3672close ! 3673endfunc 3674 3675func Test_python3_non_utf8_string () 3676smap < Esc > @< A-@ > 3677py 3 vim .command ('redir => _tmp_smaps | smap | redir END' ) 3678py 3 vim .eval ('_tmp_smaps' ).splitlines () 3679sunmap <Esc>@ 3680endfunc 3681 3682func Test_python3_fold_hidden_buffer () 3683CheckFeature folding 3684 3685set fdm = exprfde = Fde (v:lnum) 3686let b: regex = '^' 3687func Fde ( lnum ) 3688let ld = [{}] 3689let lines = bufnr ( '%' ) ->getbufline ( 1 , '$' ) 3690let was_import = 0 3691for lnum in range ( 1 , len ( lines )) 3692let line = lines [ lnum ] 3693call add ( ld , { 'a' : b: regex }) 3694let ld [ lnum ]. foldexpr = was_import ? 1 : '>1' 3695let was_import = 1 3696endfor 3697return ld [ a: lnum ]. foldexpr 3698endfunc 3699 3700call setline ( 1 , repeat ([ '' ], 15 ) + repeat ([ 'from' ], 3 )) 3701eval repeat ([ 'x' ], 17 ) ->writefile ( 'Xa.txt' ) 3702split Xa.txt 3703py 3 import vim 3704py 3 b = vim .current .buffer 3705py 3 aaa = b [:] 3706hide 3707py 3 b [:]= aaa 3708 3709call delete ( 'Xa.txt' ) 3710set fdm & fde & 3711delfunc Fde 3712bwipe ! Xa.txt 3713endfunc 3714 3715" vim: shiftwidth=2 sts=2 expandtab