Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/cpydiff: Add os module environ differences.
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |