updated for version 7.3.1172
Problem: Python 2: loading modules doesn't work well.
Solution: Fix the code. Add more tests. (ZyX)
diff --git a/src/testdir/python2/module.py b/src/testdir/python2/module.py
index 5f0a6f0..e90106a 100644
--- a/src/testdir/python2/module.py
+++ b/src/testdir/python2/module.py
@@ -1 +1,2 @@
+import before_1
dir = '2'
diff --git a/src/testdir/python3/module.py b/src/testdir/python3/module.py
index 1ccfb09..24bd036 100644
--- a/src/testdir/python3/module.py
+++ b/src/testdir/python3/module.py
@@ -1 +1,2 @@
+import before_1
dir = '3'
diff --git a/src/testdir/python_after/after.py b/src/testdir/python_after/after.py
new file mode 100644
index 0000000..5cf8fa4
--- /dev/null
+++ b/src/testdir/python_after/after.py
@@ -0,0 +1,2 @@
+import before_2
+dir = "after"
diff --git a/src/testdir/python_before/before.py b/src/testdir/python_before/before.py
new file mode 100644
index 0000000..531e81a
--- /dev/null
+++ b/src/testdir/python_before/before.py
@@ -0,0 +1 @@
+dir = "before"
diff --git a/src/testdir/test86.in b/src/testdir/test86.in
index 26c7fe2..e22ae31 100644
--- a/src/testdir/test86.in
+++ b/src/testdir/test86.in
@@ -8,6 +8,7 @@
STARTTEST
:so small.vim
:set encoding=latin1
+:set noswapfile
:if !has('python') | e! test.ok | wq! test.out | endif
:lang C
:py import vim
@@ -1071,10 +1072,16 @@
:"
:" Test import
py << EOF
+sys.path.insert(0, os.path.join(os.getcwd(), 'python_before'))
+sys.path.append(os.path.join(os.getcwd(), 'python_after'))
vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
from module import dir as d
from modulex import ddir
cb.append(d + ',' + ddir)
+import before
+cb.append(before.dir)
+import after
+cb.append(after.dir)
EOF
:"
:" Test exceptions
diff --git a/src/testdir/test86.ok b/src/testdir/test86.ok
index 145979f..e981544 100644
--- a/src/testdir/test86.ok
+++ b/src/testdir/test86.ok
@@ -1084,6 +1084,8 @@
vim.current.tabpage = True:(<type 'exceptions.TypeError'>, TypeError('expected vim.TabPage object',))
vim.current.xxx = True:(<type 'exceptions.AttributeError'>, AttributeError('xxx',))
2,xx
+before
+after
vim.command("throw 'abc'"):(<class 'vim.error'>, error('abc',))
Exe("throw 'def'"):(<class 'vim.error'>, error('def',))
vim.eval("Exe('throw ''ghi''')"):(<class 'vim.error'>, error('ghi',))
diff --git a/src/testdir/test87.in b/src/testdir/test87.in
index 7a3d583..1223ca9 100644
--- a/src/testdir/test87.in
+++ b/src/testdir/test87.in
@@ -2,6 +2,7 @@
STARTTEST
:so small.vim
+:set noswapfile
:if !has('python3') | e! test.ok | wq! test.out | endif
:lang C
:py3 import vim
@@ -1038,10 +1039,16 @@
:"
:" Test import
py3 << EOF
+sys.path.insert(0, os.path.join(os.getcwd(), 'python_before'))
+sys.path.append(os.path.join(os.getcwd(), 'python_after'))
vim.options['rtp'] = os.getcwd().replace(',', '\\,').replace('\\', '\\\\')
from module import dir as d
from modulex import ddir
cb.append(d + ',' + ddir)
+import before
+cb.append(before.dir)
+import after
+cb.append(after.dir)
EOF
:"
:" Test exceptions
diff --git a/src/testdir/test87.ok b/src/testdir/test87.ok
index 31c7df4..1d40445 100644
--- a/src/testdir/test87.ok
+++ b/src/testdir/test87.ok
@@ -1093,6 +1093,8 @@
vim.current.tabpage = True:(<class 'TypeError'>, TypeError('expected vim.TabPage object',))
vim.current.xxx = True:(<class 'AttributeError'>, AttributeError('xxx',))
3,xx
+before
+after
vim.command("throw 'abc'"):(<class 'vim.error'>, error('abc',))
Exe("throw 'def'"):(<class 'vim.error'>, error('def',))
vim.eval("Exe('throw ''ghi''')"):(<class 'vim.error'>, error('ghi',))