From e3a2e1bbf845604318fb003c4aedd4d12688354a Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Wed, 31 Jul 2013 16:03:53 +0200 Subject: [PATCH 1/7] fix for tests running subprocesses of py.test after test_argcomplete (which all still ran with argcompletion enabled) -> fail --HG-- branch : argcomplete --- testing/test_parseopt.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index 3c7194c4d..db3a82521 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -176,7 +176,7 @@ def test_addoption_parser_epilog(testdir): @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 @@ def test_argcomplete(testdir): # 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 @@ def test_argcomplete(testdir): 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() From ef2ddb6f16d5118d6bf602af9c87e09bee456e39 Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Wed, 31 Jul 2013 21:33:13 +0200 Subject: [PATCH 2/7] monkeypatch for os.environment changes --HG-- branch : argcomplete --- testing/test_parseopt.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index db3a82521..9d89e6d5b 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -174,7 +174,7 @@ def test_addoption_parser_epilog(testdir): 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 @@ def test_argcomplete(testdir): # 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 @@ def test_argcomplete(testdir): 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() From 1111d5b26b1b3cdd0ac72be33a2db8bec8a9d8ab Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 1 Aug 2013 10:37:45 +0200 Subject: [PATCH 3/7] remove an entry --- ISSUES.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/ISSUES.txt b/ISSUES.txt index 8a69511fd..859270ee2 100644 --- a/ISSUES.txt +++ b/ISSUES.txt @@ -1,10 +1,4 @@ -improve / add to dependency/test resource injection -------------------------------------------------------------- -tags: wish feature docs - -write up better examples showing the connection between -the two. refine parametrize API ------------------------------------------------------------- From 4c6a11b8e12614406b2bf6282a9fc39dcc6f21bf Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 1 Aug 2013 10:40:55 +0200 Subject: [PATCH 4/7] remove an old issue. --- ISSUES.txt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ISSUES.txt b/ISSUES.txt index 859270ee2..b5617e82c 100644 --- a/ISSUES.txt +++ b/ISSUES.txt @@ -88,20 +88,6 @@ appropriately to avoid this issue. Moreover/Alternatively, we could record which implementations of a hook succeeded and only call their teardown. -consider and document __init__ file usage in test directories ---------------------------------------------------------------- -tags: bug core - -Currently, a test module is imported with its fully qualified -package path, determined by checking __init__ files upwards. -This has the side effect that a source package at the root -of the test dir could be imported as well. This is somewhat -convenient but complicates the picture for running tests against -different versions of a package. Also, implicit sys.path -manipulations are problematic per-se. Maybe factorting out -a pytest_addsyspath hook which can be disabled from the command line -makes sense. In any case documentation/recommendations for -certain scenarios makes sense. relax requirement to have tests/testing contain an __init__ ---------------------------------------------------------------- From 23855537904f1e3734864e50b947dca1197b1337 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 1 Aug 2013 10:43:02 +0200 Subject: [PATCH 5/7] no funcargs for setup functions, rather use autouse fixtures. --- ISSUES.txt | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/ISSUES.txt b/ISSUES.txt index b5617e82c..5c8f1da4c 100644 --- a/ISSUES.txt +++ b/ISSUES.txt @@ -200,28 +200,6 @@ to further reduce py.test globality. Also consider having py.test.config and ensuretemp coming from a plugin rather than being there from the start. -consider allowing funcargs for setup methods --------------------------------------------------------------- -tags: experimental-wish - -Users have expressed the wish to have funcargs available to setup -functions. Experiment with allowing funcargs there - it might -also help to make the py.test.ensuretemp and config deprecation. -For filling funcargs for setup methods, we could call funcarg -factories with a request object that not have a cls/function -attributes. However, how to handle parametrized test functions -and funcargs? - -maybe introduce a setup method like: - - setup_invocation(self, request) - -which has full access to the test invocation through "request" -through which you can get funcargvalues, use cached_setup etc. -Therefore, the access to funcargs would be indirect but it -could be consistently implemented. setup_invocation() would -be a "glue" function for bringing together the xUnit and funcargs -world. consider pytest_addsyspath hook ----------------------------------------- From 64e9956770576c1fc4029cc0b4e7dededba65582 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 1 Aug 2013 10:57:36 +0200 Subject: [PATCH 6/7] plugin versions are displayed now. --- ISSUES.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ISSUES.txt b/ISSUES.txt index 5c8f1da4c..546cd035f 100644 --- a/ISSUES.txt +++ b/ISSUES.txt @@ -213,13 +213,6 @@ Alternatively it could also be done via the config object and pytest_configure. -show plugin information in test header ----------------------------------------------------------------- -tags: feature - -Now that external plugins are becoming more numerous -it would be useful to have external plugins along with -their versions displayed as a header line. deprecate global py.test.config usage ---------------------------------------------------------------- From b81c2573602ce5d6ee8fd6d73d520b011c7dc23f Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 1 Aug 2013 10:59:45 +0200 Subject: [PATCH 7/7] small mod to test BND --- ISSUES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ISSUES.txt b/ISSUES.txt index 546cd035f..f1cfeb892 100644 --- a/ISSUES.txt +++ b/ISSUES.txt @@ -203,7 +203,7 @@ a plugin rather than being there from the start. consider pytest_addsyspath hook ----------------------------------------- -tags: +tags: wish py.test could call a new pytest_addsyspath() in order to systematically allow manipulation of sys.path and to inhibit it via --no-addsyspath