From 3c2d7563d26ab457c84e6392c103bce6d2fc6e02 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 13 Dec 2022 12:08:12 -0600 Subject: [PATCH] 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 --- tests/unix/mod_os.py | 21 +++++++++++++++++++++ tests/unix/mod_os.py.exp | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/unix/mod_os.py create mode 100644 tests/unix/mod_os.py.exp diff --git a/tests/unix/mod_os.py b/tests/unix/mod_os.py new file mode 100644 index 0000000000..17554d9375 --- /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()) diff --git a/tests/unix/mod_os.py.exp b/tests/unix/mod_os.py.exp new file mode 100644 index 0000000000..465163085b --- /dev/null +++ b/tests/unix/mod_os.py.exp @@ -0,0 +1,7 @@ +TEST_VALUE +TEST_VALUE +None +TEST_DEFAULT_VALUE +0 +True 4 +2