diff options
author | Damien George <damien@micropython.org> | 2023-11-20 23:04:55 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2024-02-07 13:25:09 +1100 |
commit | b87bbaeb43ddbd603b6ac3266ccc15815198b5a7 (patch) | |
tree | 768abedede5042051967a9e73d6354619a4acd71 /tests/micropython/builtin_execfile.py | |
parent | 5804aa020452c9fe115c53ce9514b442945832bb (diff) |
tests: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/micropython/builtin_execfile.py')
-rw-r--r-- | tests/micropython/builtin_execfile.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/tests/micropython/builtin_execfile.py b/tests/micropython/builtin_execfile.py index 9b6d6a0aa..a905521c6 100644 --- a/tests/micropython/builtin_execfile.py +++ b/tests/micropython/builtin_execfile.py @@ -1,11 +1,10 @@ # Test builtin execfile function using VFS. try: - import io, os + import io, os, vfs execfile io.IOBase - os.mount except (ImportError, NameError, AttributeError): print("SKIP") raise SystemExit @@ -44,25 +43,21 @@ class Filesystem: # First umount any existing mount points the target may have. try: - import io, os - - os.umount("/") + vfs.umount("/") except OSError: pass for path in os.listdir("/"): - os.umount("/" + path) + vfs.umount("/" + path) # Create and mount the VFS object. files = { "/test.py": "print(123)", } fs = Filesystem(files) -os.mount(fs, "/test_mnt") +vfs.mount(fs, "/test_mnt") # Test execfile with a file that doesn't exist. try: - import io, os - execfile("/test_mnt/noexist.py") except OSError: print("OSError") @@ -77,4 +72,4 @@ except TypeError: print("TypeError") # Unmount the VFS object. -os.umount(fs) +vfs.umount(fs) |