mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
avoid fragility: make sure POSIXLY_CORRECT is completely controlled
for the tests, and restored properly when done
This commit is contained in:
parent
34fba3b445
commit
4354ba3f76
1 changed files with 10 additions and 1 deletions
|
@ -16,6 +16,10 @@ def expectException(teststr, expected, failure=AssertionError):
|
|||
else:
|
||||
raise failure
|
||||
|
||||
old_posixly_correct = os.environ.get("POSIXLY_CORRECT")
|
||||
if old_posixly_correct is not None:
|
||||
del os.environ["POSIXLY_CORRECT"]
|
||||
|
||||
if verbose:
|
||||
print 'Running tests on getopt.short_has_arg'
|
||||
verify(getopt.short_has_arg('a', 'a:'))
|
||||
|
@ -124,7 +128,12 @@ os.environ["POSIXLY_CORRECT"] = "1"
|
|||
opts, args = getopt.gnu_getopt(cmdline, 'ab:', ['alpha', 'beta='])
|
||||
verify(opts == [('-a', '')])
|
||||
verify(args == ['arg1', '-b', '1', '--alpha', '--beta=2'])
|
||||
del os.environ["POSIXLY_CORRECT"]
|
||||
|
||||
|
||||
if old_posixly_correct is None:
|
||||
del os.environ["POSIXLY_CORRECT"]
|
||||
else:
|
||||
os.environ["POSIXLY_CORRECT"] = old_posixly_correct
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue