3 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/e2889c9a0d75/ Changeset: e2889c9a0d75 Branch: argcomplete User: Anthon van der Neut Date: 2013-07-31 16:03:53 Summary: fix for tests running subprocesses of py.test after test_argcomplete (which all still ran with argcompletion enabled) -> fail Affected #: 1 file
diff -r f44d44a4142b72a260007e413e6419549b3c1dc1 -r e2889c9a0d75963201f2d098482f28002a199f6f testing/test_parseopt.py --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -176,7 +176,7 @@ @pytest.mark.skipif("sys.version_info < (2,5)") def test_argcomplete(testdir): if not py.path.local.sysfind('bash'): - pytest.skip("bash not available") + pytest.skip("bash not available") import os script = os.path.join(os.getcwd(), 'test_argcomplete') with open(str(script), 'w') as fp: @@ -185,6 +185,10 @@ # so we use bash fp.write('COMP_WORDBREAKS="$COMP_WORDBREAKS" $(which py.test) ' '8>&1 9>&2') + # alternative would be exteneded Testdir.{run(),_run(),popen()} to be able + # to handle a keyword argument env that replaces os.environ in popen or + # extends the copy, advantage: could not forget to restore + orgenv = os.environ.copy() os.environ['_ARGCOMPLETE'] = "1" os.environ['_ARGCOMPLETE_IFS'] = "\x0b" os.environ['COMP_WORDBREAKS'] = ' \\t\\n"\\\'><=;|&(:' @@ -206,3 +210,5 @@ os.environ['COMP_POINT'] = str(len(os.environ['COMP_LINE'])) result = testdir.run('bash', str(script), arg) result.stdout.fnmatch_lines(["test_argcomplete", "test_argcomplete.d/"]) + # restore environment + os.environ = orgenv.copy() https://bitbucket.org/hpk42/pytest/commits/5ac465ea2d43/ Changeset: 5ac465ea2d43 Branch: argcomplete User: Anthon van der Neut Date: 2013-07-31 21:33:13 Summary: monkeypatch for os.environment changes Affected #: 1 file diff -r e2889c9a0d75963201f2d098482f28002a199f6f -r 5ac465ea2d438ae71524197ecfd5a8f4ce2d4d90 testing/test_parseopt.py --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -174,7 +174,7 @@ result.stdout.fnmatch_lines(["hint: hello world", "hint: from me too"]) @pytest.mark.skipif("sys.version_info < (2,5)") -def test_argcomplete(testdir): +def test_argcomplete(testdir, monkeypatch): if not py.path.local.sysfind('bash'): pytest.skip("bash not available") import os @@ -188,14 +188,13 @@ # alternative would be exteneded Testdir.{run(),_run(),popen()} to be able # to handle a keyword argument env that replaces os.environ in popen or # extends the copy, advantage: could not forget to restore - orgenv = os.environ.copy() - os.environ['_ARGCOMPLETE'] = "1" - os.environ['_ARGCOMPLETE_IFS'] = "\x0b" - os.environ['COMP_WORDBREAKS'] = ' \\t\\n"\\\'><=;|&(:' + monkeypatch.setenv('_ARGCOMPLETE', "1") + monkeypatch.setenv('_ARGCOMPLETE_IFS',"\x0b") + monkeypatch.setenv('COMP_WORDBREAKS', ' \\t\\n"\\\'><=;|&(:') arg = '--fu' - os.environ['COMP_LINE'] = "py.test " + arg - os.environ['COMP_POINT'] = str(len(os.environ['COMP_LINE'])) + monkeypatch.setenv('COMP_LINE', "py.test " + arg) + monkeypatch.setenv('COMP_POINT', str(len("py.test " + arg))) result = testdir.run('bash', str(script), arg) print dir(result), result.ret if result.ret == 255: @@ -206,9 +205,8 @@ os.mkdir('test_argcomplete.d') arg = 'test_argc' - os.environ['COMP_LINE'] = "py.test " + arg - os.environ['COMP_POINT'] = str(len(os.environ['COMP_LINE'])) + monkeypatch.setenv('COMP_LINE', "py.test " + arg) + monkeypatch.setenv('COMP_POINT', str(len('py.test ' + arg))) result = testdir.run('bash', str(script), arg) result.stdout.fnmatch_lines(["test_argcomplete", "test_argcomplete.d/"]) # restore environment - os.environ = orgenv.copy() https://bitbucket.org/hpk42/pytest/commits/b425db448787/ Changeset: b425db448787 User: hpk42 Date: 2013-08-01 10:30:24 Summary: Merged in anthon_van_der_neut/pytest/argcomplete (pull request #51) fix for tests running subprocesses of py.test after test_argcomplete Affected #: 1 file diff -r 2d92b2270aba23d130c8e75c4f145e1e45427deb -r b425db44878707b9688b8d4d179be349e341afed testing/test_parseopt.py --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -174,9 +174,9 @@ result.stdout.fnmatch_lines(["hint: hello world", "hint: from me too"]) @pytest.mark.skipif("sys.version_info < (2,5)") -def test_argcomplete(testdir): +def test_argcomplete(testdir, monkeypatch): if not py.path.local.sysfind('bash'): - pytest.skip("bash not available") + pytest.skip("bash not available") import os script = os.path.join(os.getcwd(), 'test_argcomplete') with open(str(script), 'w') as fp: @@ -185,13 +185,16 @@ # so we use bash fp.write('COMP_WORDBREAKS="$COMP_WORDBREAKS" $(which py.test) ' '8>&1 9>&2') - os.environ['_ARGCOMPLETE'] = "1" - os.environ['_ARGCOMPLETE_IFS'] = "\x0b" - os.environ['COMP_WORDBREAKS'] = ' \\t\\n"\\\'><=;|&(:' + # alternative would be exteneded Testdir.{run(),_run(),popen()} to be able + # to handle a keyword argument env that replaces os.environ in popen or + # extends the copy, advantage: could not forget to restore + monkeypatch.setenv('_ARGCOMPLETE', "1") + monkeypatch.setenv('_ARGCOMPLETE_IFS',"\x0b") + monkeypatch.setenv('COMP_WORDBREAKS', ' \\t\\n"\\\'><=;|&(:') arg = '--fu' - os.environ['COMP_LINE'] = "py.test " + arg - os.environ['COMP_POINT'] = str(len(os.environ['COMP_LINE'])) + monkeypatch.setenv('COMP_LINE', "py.test " + arg) + monkeypatch.setenv('COMP_POINT', str(len("py.test " + arg))) result = testdir.run('bash', str(script), arg) print dir(result), result.ret if result.ret == 255: @@ -202,7 +205,8 @@ os.mkdir('test_argcomplete.d') arg = 'test_argc' - os.environ['COMP_LINE'] = "py.test " + arg - os.environ['COMP_POINT'] = str(len(os.environ['COMP_LINE'])) + monkeypatch.setenv('COMP_LINE', "py.test " + arg) + monkeypatch.setenv('COMP_POINT', str(len('py.test ' + arg))) result = testdir.run('bash', str(script), arg) result.stdout.fnmatch_lines(["test_argcomplete", "test_argcomplete.d/"]) + # restore environment Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org http://mail.python.org/mailman/listinfo/pytest-commit