From dcc2c6c3651219b0643d7672c7bf2b8ec2b52414 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sun, 4 Aug 2019 15:20:54 +0100 Subject: [PATCH 1/3] Manual python test --- python3/vimspector/debug_session.py | 5 ++--- .../test/python/simple_python/.vimspector.json | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 support/test/python/simple_python/.vimspector.json diff --git a/python3/vimspector/debug_session.py b/python3/vimspector/debug_session.py index 64d14df..08e58ef 100644 --- a/python3/vimspector/debug_session.py +++ b/python3/vimspector/debug_session.py @@ -61,7 +61,7 @@ class DebugSession( object ): 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 = {} ): @@ -671,8 +671,7 @@ class DebugSession( object ): 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 ) diff --git a/support/test/python/simple_python/.vimspector.json b/support/test/python/simple_python/.vimspector.json new file mode 100644 index 0000000..13e996c --- /dev/null +++ b/support/test/python/simple_python/.vimspector.json @@ -0,0 +1,15 @@ +{ + "configurations": { + "run": { + "adapter": "vscode-python", + "configuration": { + "request": "launch", + "type": "python", + "cwd": "${workspaceRoot}", + "program": "${file}", + "stopOnEntry": true, + "console": "integratedTerminal" + } + } + } +} From 53d3f8f64b2e158c174addda1c4f022c671e1881 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sun, 4 Aug 2019 19:37:23 +0100 Subject: [PATCH 2/3] Fix inputrestore --- python3/vimspector/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python3/vimspector/utils.py b/python3/vimspector/utils.py index 796aa21..9c56e8b 100644 --- a/python3/vimspector/utils.py +++ b/python3/vimspector/utils.py @@ -242,7 +242,7 @@ def InputSave(): vim.eval( 'inputsave()' ) try: yield - except Exception: + finally: vim.eval( 'inputrestore()' ) @@ -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 ) ) ) From 6734a94ba851bda72d3a434ebdab32e854db7e3d Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Tue, 6 Aug 2019 20:58:48 +0100 Subject: [PATCH 3/3] Python auto test --- tests/language_python.test.vim | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/language_python.test.vim diff --git a/tests/language_python.test.vim b/tests/language_python.test.vim new file mode 100644 index 0000000..5e9b845 --- /dev/null +++ b/tests/language_python.test.vim @@ -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( "\", '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( "\", "xt" )' ) + vim.eval( 'vimspector#test#signs#AssertCursorIsAtLineInBuffer( fn, 6, 1 )' ) + p.assert_called() +EOF + + " Step + call feedkeys( "\", '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 +