aboutsummaryrefslogtreecommitdiff
path: root/tests/extmod
diff options
context:
space:
mode:
authorDamien George2020-05-14 21:37:59 +1000
committerDamien George2020-05-15 11:31:32 +1000
commit7dffbfd22a128d88cd4cd7f23ebf24c46ae8791f (patch)
treea975ad37bd465e94146fe6a1cc03eaf18081a9e2 /tests/extmod
parent463c0fb2f4fa5dfd79598c4d8681a007704c2ee1 (diff)
extmod/vfs_lfsx: Fix import_stat so it takes into account current dir.
CPython semantics require searching the current directory if the import is not absolute (when "" is in sys.path). Fixes issue #6037.
Diffstat (limited to 'tests/extmod')
-rw-r--r--tests/extmod/vfs_lfs_mount.py7
-rw-r--r--tests/extmod/vfs_lfs_mount.py.exp2
2 files changed, 9 insertions, 0 deletions
diff --git a/tests/extmod/vfs_lfs_mount.py b/tests/extmod/vfs_lfs_mount.py
index 7ac19184b..9207f4a8c 100644
--- a/tests/extmod/vfs_lfs_mount.py
+++ b/tests/extmod/vfs_lfs_mount.py
@@ -58,6 +58,12 @@ def test(bdev, vfs_class):
f.write('print("package")\n')
import lfspkg
+ # chdir and import module from current directory (needs "" in sys.path)
+ uos.mkdir("/lfs/subdir")
+ uos.chdir("/lfs/subdir")
+ uos.rename("/lfs/lfsmod.py", "/lfs/subdir/lfsmod2.py")
+ import lfsmod2
+
# umount
uos.umount("/lfs")
@@ -72,6 +78,7 @@ import sys
sys.path.clear()
sys.path.append("/lfs")
+sys.path.append("")
# run tests
test(bdev, uos.VfsLfs1)
diff --git a/tests/extmod/vfs_lfs_mount.py.exp b/tests/extmod/vfs_lfs_mount.py.exp
index 90aff3501..b5c521531 100644
--- a/tests/extmod/vfs_lfs_mount.py.exp
+++ b/tests/extmod/vfs_lfs_mount.py.exp
@@ -1,6 +1,8 @@
test <class 'VfsLfs1'>
hello from lfs
package
+hello from lfs
test <class 'VfsLfs2'>
hello from lfs
package
+hello from lfs