tests/cpydiff: Add os module environ differences.
This commit is contained in:
parent
4a97f7aaf3
commit
74106757ac
16
tests/cpydiff/modules_os_environ.py
Normal file
16
tests/cpydiff/modules_os_environ.py
Normal file
@ -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'))
|
10
tests/cpydiff/modules_os_getenv.py
Normal file
10
tests/cpydiff/modules_os_getenv.py
Normal file
@ -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'))
|
13
tests/cpydiff/modules_os_getenv_argcount.py
Normal file
13
tests/cpydiff/modules_os_getenv_argcount.py
Normal file
@ -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')
|
Loading…
x
Reference in New Issue
Block a user