summaryrefslogtreecommitdiff
path: root/tests/unix/mod_os.py
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2022-12-13 12:08:12 -0600
committerDamien George <damien@micropython.org>2022-12-14 13:38:51 +1100
commit3c2d7563d26ab457c84e6392c103bce6d2fc6e02 (patch)
tree117caf46fbd515ca622c942ca5e89a5fe01b7499 /tests/unix/mod_os.py
parent958f748e53ec03c8880e9e208498de5a101362b4 (diff)
tests/unix/mod_os: Add test for os module.
This adds a test to get coverage of the unix port-specific implementation of the `os` module. Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'tests/unix/mod_os.py')
-rw-r--r--tests/unix/mod_os.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unix/mod_os.py b/tests/unix/mod_os.py
new file mode 100644
index 000000000..17554d937
--- /dev/null
+++ b/tests/unix/mod_os.py
@@ -0,0 +1,21 @@
+# This module is not entirely compatible with CPython
+import os
+
+
+os.putenv("TEST_VARIABLE", "TEST_VALUE")
+
+print(os.getenv("TEST_VARIABLE"))
+print(os.getenv("TEST_VARIABLE", "TEST_DEFAULT_VALUE"))
+
+os.unsetenv("TEST_VARIABLE")
+
+print(os.getenv("TEST_VARIABLE"))
+print(os.getenv("TEST_VARIABLE", "TEST_DEFAULT_VALUE"))
+
+print(os.system("true"))
+
+rand = os.urandom(4)
+print(type(rand) is bytes, len(rand))
+
+os.errno(2)
+print(os.errno())