diff options
author | David Lechner <david@pybricks.com> | 2020-02-02 15:33:09 -0600 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-02-04 17:54:31 +1100 |
commit | 74106757ac4f78609f71083a6452ce5ba7edb3c2 (patch) | |
tree | 4ef52c36b222163012be0d4249376a2e8accf32e /tests | |
parent | 4a97f7aaf3c9123a7f127d6986b0f61ce9361beb (diff) | |
download | micropython-74106757ac4f78609f71083a6452ce5ba7edb3c2.tar.gz micropython-74106757ac4f78609f71083a6452ce5ba7edb3c2.zip |
tests/cpydiff: Add os module environ differences.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cpydiff/modules_os_environ.py | 16 | ||||
-rw-r--r-- | tests/cpydiff/modules_os_getenv.py | 10 | ||||
-rw-r--r-- | tests/cpydiff/modules_os_getenv_argcount.py | 13 |
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/cpydiff/modules_os_environ.py b/tests/cpydiff/modules_os_environ.py new file mode 100644 index 0000000000..db471a159e --- /dev/null +++ b/tests/cpydiff/modules_os_environ.py @@ -0,0 +1,16 @@ +""" +categories: Modules,os +description: ``environ`` attribute is not implemented +cause: Unknown +workaround: Use ``getenv``, ``putenv`` and ``unsetenv`` +""" +import os +try: + print(os.environ.get('NEW_VARIABLE')) + os.environ['NEW_VARIABLE'] = 'VALUE' + print(os.environ['NEW_VARIABLE']) +except AttributeError: + print('should not get here') + print(os.getenv('NEW_VARIABLE')) + os.putenv('NEW_VARIABLE', 'VALUE') + print(os.getenv('NEW_VARIABLE')) diff --git a/tests/cpydiff/modules_os_getenv.py b/tests/cpydiff/modules_os_getenv.py new file mode 100644 index 0000000000..1313755564 --- /dev/null +++ b/tests/cpydiff/modules_os_getenv.py @@ -0,0 +1,10 @@ +""" +categories: Modules,os +description: ``getenv`` returns actual value instead of cached value +cause: The ``environ`` attribute is not implemented +workaround: Unknown +""" +import os +print(os.getenv('NEW_VARIABLE')) +os.putenv('NEW_VARIABLE', 'VALUE') +print(os.getenv('NEW_VARIABLE')) diff --git a/tests/cpydiff/modules_os_getenv_argcount.py b/tests/cpydiff/modules_os_getenv_argcount.py new file mode 100644 index 0000000000..375cf614b2 --- /dev/null +++ b/tests/cpydiff/modules_os_getenv_argcount.py @@ -0,0 +1,13 @@ +""" +categories: Modules,os +description: ``getenv`` only allows one argument +cause: Unknown +workaround: Test that the return value is ``None`` +""" +import os +try: + print(os.getenv('NEW_VARIABLE', 'DEFAULT')) +except TypeError: + print('should not get here') + # this assumes NEW_VARIABLE is never an empty variable + print(os.getenv('NEW_VARIABLE') or 'DEFAULT') |