diff options
author | Fred Drake <fdrake@acm.org> | 2004-08-03 15:54:45 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2004-08-03 15:54:45 (GMT) |
commit | 4354ba3f762cbb2b1d6140d3f4297443af5ef1ff (patch) | |
tree | 9768489c7e111ee429d2e4f13bbc98ab3dde8cd2 /Lib/test | |
parent | 34fba3b445f16e17ce782b3642937112f3bc5868 (diff) | |
download | cpython-4354ba3f762cbb2b1d6140d3f4297443af5ef1ff.zip cpython-4354ba3f762cbb2b1d6140d3f4297443af5ef1ff.tar.gz cpython-4354ba3f762cbb2b1d6140d3f4297443af5ef1ff.tar.bz2 |
avoid fragility: make sure POSIXLY_CORRECT is completely controlled
for the tests, and restored properly when done
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_getopt.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py index da53593..9856a6a 100644 --- a/Lib/test/test_getopt.py +++ b/Lib/test/test_getopt.py @@ -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 #------------------------------------------------------------------------------ |