Skip to content

Commit 5673232

Browse files
committed
extmod/vfs_posix: Additional tests for coverage of error cases.
Signed-off-by: Christian Walther <cwalther@gmx.ch>
1 parent 3b61b32 commit 5673232

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

tests/extmod/vfs_posix_enoent.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Test for VfsPosix error conditions
2+
3+
try:
4+
import os
5+
import sys
6+
7+
os.VfsPosix
8+
except (ImportError, AttributeError):
9+
print("SKIP")
10+
raise SystemExit
11+
12+
if sys.platform == "win32":
13+
# Windows doesn't let you delete the current directory, so this cannot be
14+
# tested.
15+
print("SKIP")
16+
raise SystemExit
17+
18+
# We need an empty directory for testing.
19+
# Skip the test if it already exists.
20+
temp_dir = "vfs_posix_enoent_test_dir"
21+
try:
22+
os.stat(temp_dir)
23+
print("SKIP")
24+
raise SystemExit
25+
except OSError:
26+
pass
27+
28+
curdir = os.getcwd()
29+
os.mkdir(temp_dir)
30+
os.chdir(temp_dir)
31+
os.rmdir(curdir + "/" + temp_dir)
32+
try:
33+
print("getcwd():", os.getcwd())
34+
except OSError as e:
35+
# expecting ENOENT = 2
36+
print("getcwd():", repr(e))
37+
38+
try:
39+
print("VfsPosix():", os.VfsPosix("something"))
40+
except OSError as e:
41+
# expecting ENOENT = 2
42+
print("VfsPosix():", repr(e))

tests/extmod/vfs_posix_enoent.py.exp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
getcwd(): OSError(2,)
2+
VfsPosix(): OSError(2,)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy