Skip to content

Commit

Permalink
Merge pull request #51 from puremourning/python
Browse files Browse the repository at this point in the history
Python test
  • Loading branch information
mergify[bot] authored Aug 6, 2019
2 parents daf3b80 + 6734a94 commit 4de1269
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
5 changes: 2 additions & 3 deletions python3/vimspector/debug_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _ResetServerState( self ):
self._configuration = None
self._init_complete = False
self._launch_complete = False
self._on_init_complete_handlers = None
self._on_init_complete_handlers = []
self._server_capabilities = {}

def Start( self, launch_variables = {} ):
Expand Down Expand Up @@ -671,8 +671,7 @@ def _LoadThreadsIfReady( self ):
if self._launch_complete and self._init_complete:
for h in self._on_init_complete_handlers:
h()

self._on_init_complete_handlers = None
self._on_init_complete_handlers = []

self._stackTraceView.LoadThreads( True )

Expand Down
3 changes: 1 addition & 2 deletions python3/vimspector/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def InputSave():
vim.eval( 'inputsave()' )
try:
yield
except Exception:
finally:
vim.eval( 'inputrestore()' )


Expand All @@ -262,7 +262,6 @@ def SelectFromList( prompt, options ):


def AskForInput( prompt ):
# TODO: Handle the ctrl-c and such responses returning empty or something
with InputSave():
try:
return vim.eval( "input( '{0}' )".format( Escape( prompt ) ) )
Expand Down
15 changes: 15 additions & 0 deletions support/test/python/simple_python/.vimspector.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": {
"run": {
"adapter": "vscode-python",
"configuration": {
"request": "launch",
"type": "python",
"cwd": "${workspaceRoot}",
"program": "${file}",
"stopOnEntry": true,
"console": "integratedTerminal"
}
}
}
}
55 changes: 55 additions & 0 deletions tests/language_python.test.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
function! SetUp()
call vimspector#test#setup#SetUpWithMappings( v:none )
endfunction

function! ClearDown()
call vimspector#test#setup#ClearDown()
endfunction

function! SetUp_Test_Go_Simple()
let g:vimspector_enable_mappings = 'HUMAN'
endfunction

function! Test_Go_Simple()
let fn='main.py'
lcd ../support/test/python/simple_python
exe 'edit ' . fn
call setpos( '.', [ 0, 6, 1 ] )

call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )
call vimspector#test#signs#AssertSignGroupEmptyAtLine( 'VimspectorBP', 6 )

" Add the breakpoint
call feedkeys( "\<F9>", 'xt' )
call vimspector#test#signs#AssertSignGroupSingletonAtLine( 'VimspectorBP',
\ 6,
\ 'vimspectorBP' )

call setpos( '.', [ 0, 1, 1 ] )

" Here we go. Start Debugging
pyx << EOF
from unittest.mock import patch
with patch( 'vimspector.utils.SelectFromList',
return_value=None ) as p:
with patch( 'vimspector.utils.AskForInput',
return_value=None ) as p:
vim.eval( 'feedkeys( "\<F5>", "xt" )' )
vim.eval( 'vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )' )
p.assert_called()
EOF

" Step
call feedkeys( "\<F10>", 'xt' )

call vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 7, 1 )
call WaitForAssert( {->
\ vimspector#test#signs#AssertPCIsAtLineInBuffer( fn, 7 )
\ } )

call vimspector#test#setup#Reset()

lcd -
%bwipeout!
endfunction

0 comments on commit 4de1269

Please sign in to comment.