patch 8.2.1146: not enough testing for Python

Problem:    Not enough testing for Python.
Solution:   Add more tests.  Fix uncovered problems. (Yegappan Lakshmanan,
            closes #6392)
diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim
index 3e0929c..bbd28be 100644
--- a/src/testdir/shared.vim
+++ b/src/testdir/shared.vim
@@ -353,4 +353,19 @@
   return msg_list
 endfunc
 
+" Run the list of commands in 'cmds' and look for 'errstr' in exception.
+" Note that assert_fails() cannot be used in some places and this function
+" can be used.
+func AssertException(cmds, errstr)
+  let save_exception = ''
+  try
+    for cmd in a:cmds
+      exe cmd
+    endfor
+  catch
+    let save_exception = v:exception
+  endtry
+  call assert_match(a:errstr, save_exception)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab