From issues-reply at bitbucket.org Mon Apr 1 06:41:47 2013 From: issues-reply at bitbucket.org (mears) Date: Mon, 01 Apr 2013 04:41:47 -0000 Subject: [Pytest-commit] [hpk42/pytest] Allow funcargs to be used in conjunction with default argument values (issue #285) Message-ID: <20130401044147.12870.32446@bitbucket25.managed.contegix.com> New issue 285: Allow funcargs to be used in conjunction with default argument values https://bitbucket.org/hpk42/pytest/issue/285/allow-funcargs-to-be-used-in-conjunction mears: It appears that dependency injection only works if an argument is unresolved. It would be really nice if py.test would also support injecting arguments that have default values. Basically, the funcarg lookup would consider all test method arguments, including arguments with default values. If no funcarg exists for the argument with a default, it would be left unset with pytest invokes it. -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From issues-reply at bitbucket.org Mon Apr 1 06:46:01 2013 From: issues-reply at bitbucket.org (mears) Date: Mon, 01 Apr 2013 04:46:01 -0000 Subject: [Pytest-commit] [hpk42/pytest] Add ability to inject arguments to xunit setup/teardown (issue #286) Message-ID: <20130401044601.21461.37768@bitbucket24.managed.contegix.com> New issue 286: Add ability to inject arguments to xunit setup/teardown https://bitbucket.org/hpk42/pytest/issue/286/add-ability-to-inject-arguments-to-xunit mears: In some cases, the age old setup/teardown methods are a bit more convenient than fixtures. Currently, pytest doesn't support dependency injection with these xunit constructs. It would be nice if they could receive injected arguments. -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From issues-reply at bitbucket.org Tue Apr 2 08:58:25 2013 From: issues-reply at bitbucket.org (Andreas Pelme) Date: Tue, 02 Apr 2013 06:58:25 -0000 Subject: [Pytest-commit] [hpk42/pytest] Fixture finalizer failure causes other finalizers to not be run (issue #287) Message-ID: <20130402065825.14194.85625@bitbucket20.managed.contegix.com> New issue 287: Fixture finalizer failure causes other finalizers to not be run https://bitbucket.org/hpk42/pytest/issue/287/fixture-finalizer-failure-causes-other Andreas Pelme: When tearing down fixtures and one finalizer (registered via `request.addfinalizer`) fails (with an uncaught exception or with `pytest.fail`) - no other finalizers will be run. Of course - the fixture finalizer could be fixed to not throw exceptions and the problem would go away. However, I find it useful to be able to make assertions in the fixture teardown. I have a stubbing fixture (similar to pytest's monkeypatch). It checks that the stubbed methods actually was called during the tests, and triggers assertions otherwise. When this happens in one test case, it causes database fixture and all other kinds of failures for all other tests. I am not sure this is a valid use case for fixtures, if not, feel free to close it. :) -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From commits-noreply at bitbucket.org Tue Apr 2 10:29:24 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 02 Apr 2013 08:29:24 -0000 Subject: [Pytest-commit] commit/pytest-xdist: 2 new changesets Message-ID: <20130402082924.20050.34183@bitbucket04.managed.contegix.com> 2 new commits in pytest-xdist: https://bitbucket.org/hpk42/pytest-xdist/commits/f13b083b8030/ Changeset: f13b083b8030 Branch: dedupe-failures User: jerith Date: 2013-03-27 16:34:58 Summary: Avoid collecting duplicate failures when using --looponfail. Affected #: 2 files diff -r db56e4b41e9bff631eec7b1f3db9dd5cf1b3e574 -r f13b083b80301f7aa51f657916e023e87c4201ee testing/test_looponfail.py --- a/testing/test_looponfail.py +++ b/testing/test_looponfail.py @@ -206,6 +206,24 @@ remotecontrol.loop_once() assert len(remotecontrol.failures) == 1 + def test_looponfail_multiple_errors(self, testdir, monkeypatch): + modcol = testdir.getmodulecol(""" + def test_one(): + assert 0 + """) + remotecontrol = RemoteControl(modcol.config) + orig_runsession = remotecontrol.runsession + + def runsession_dups(): + # twisted.trial test cases may report multiple errors. + failures, reports, collection_failed = orig_runsession() + print failures + return failures * 2, reports, collection_failed + + monkeypatch.setattr(remotecontrol, 'runsession', runsession_dups) + remotecontrol.loop_once() + assert len(remotecontrol.failures) == 1 + class TestFunctional: def test_fail_to_ok(self, testdir): diff -r db56e4b41e9bff631eec7b1f3db9dd5cf1b3e574 -r f13b083b80301f7aa51f657916e023e87c4201ee xdist/looponfail.py --- a/xdist/looponfail.py +++ b/xdist/looponfail.py @@ -89,7 +89,11 @@ if collection_failed: reports = ["Collection failed, keeping previous failure set"] else: - self.failures = failures + uniq_failures = [] + for failure in failures: + if failure not in uniq_failures: + uniq_failures.append(failure) + self.failures = uniq_failures def repr_pytest_looponfailinfo(failreports, rootdirs): tr = py.io.TerminalWriter() https://bitbucket.org/hpk42/pytest-xdist/commits/af184e3fe6c2/ Changeset: af184e3fe6c2 User: hpk42 Date: 2013-04-02 10:29:21 Summary: Merged in jerith/pytest-xdist/dedupe-failures (pull request #1) Avoid collecting duplicate failures when using --looponfail. Affected #: 2 files diff -r db56e4b41e9bff631eec7b1f3db9dd5cf1b3e574 -r af184e3fe6c230fe46b99aca86707eba196957f7 testing/test_looponfail.py --- a/testing/test_looponfail.py +++ b/testing/test_looponfail.py @@ -206,6 +206,24 @@ remotecontrol.loop_once() assert len(remotecontrol.failures) == 1 + def test_looponfail_multiple_errors(self, testdir, monkeypatch): + modcol = testdir.getmodulecol(""" + def test_one(): + assert 0 + """) + remotecontrol = RemoteControl(modcol.config) + orig_runsession = remotecontrol.runsession + + def runsession_dups(): + # twisted.trial test cases may report multiple errors. + failures, reports, collection_failed = orig_runsession() + print failures + return failures * 2, reports, collection_failed + + monkeypatch.setattr(remotecontrol, 'runsession', runsession_dups) + remotecontrol.loop_once() + assert len(remotecontrol.failures) == 1 + class TestFunctional: def test_fail_to_ok(self, testdir): diff -r db56e4b41e9bff631eec7b1f3db9dd5cf1b3e574 -r af184e3fe6c230fe46b99aca86707eba196957f7 xdist/looponfail.py --- a/xdist/looponfail.py +++ b/xdist/looponfail.py @@ -89,7 +89,11 @@ if collection_failed: reports = ["Collection failed, keeping previous failure set"] else: - self.failures = failures + uniq_failures = [] + for failure in failures: + if failure not in uniq_failures: + uniq_failures.append(failure) + self.failures = uniq_failures def repr_pytest_looponfailinfo(failreports, rootdirs): tr = py.io.TerminalWriter() Repository URL: https://bitbucket.org/hpk42/pytest-xdist/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. From commits-noreply at bitbucket.org Tue Apr 2 10:33:54 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 02 Apr 2013 08:33:54 -0000 Subject: [Pytest-commit] commit/pytest-xdist: 4 new changesets Message-ID: <20130402083354.1942.5542@bitbucket21.managed.contegix.com> 4 new commits in pytest-xdist: https://bitbucket.org/hpk42/pytest-xdist/commits/d9fe8e544abf/ Changeset: d9fe8e544abf User: hpk42 Date: 2012-11-20 13:26:29 Summary: add boxed example Affected #: 1 file diff -r db56e4b41e9bff631eec7b1f3db9dd5cf1b3e574 -r d9fe8e544abfb630e9126c0d1a29ab9795c510d6 example/boxed.txt --- /dev/null +++ b/example/boxed.txt @@ -0,0 +1,62 @@ + + +If your testing involves C or C++ libraries you might have to deal +with crashing processes. The xdist-plugin provides the ``--boxed`` option +to run each test in a controled subprocess. Here is a basic example:: + + # content of test_module.py + + import pytest + import os + import time + + # run test function 50 times with different argument + @pytest.mark.parametrize("arg", range(50)) + def test_func(arg): + time.sleep(0.05) # each tests takes a while + if arg % 19 == 0: + os.kill(os.getpid(), 15) + +If you run this with:: + + $ py.test --boxed + =========================== test session starts ============================ + platform linux2 -- Python 2.7.3 -- pytest-2.3.0.dev8 + plugins: xdist, bugzilla, cache, oejskit, cli, pep8, cov + collecting ... collected 50 items + + test_module.py f..................f..................f........... + + ================================= FAILURES ================================= + _______________________________ test_func[0] _______________________________ + /home/hpk/tmp/doc-exec-420/test_module.py:6: running the test CRASHED with signal 15 + ______________________________ test_func[19] _______________________________ + /home/hpk/tmp/doc-exec-420/test_module.py:6: running the test CRASHED with signal 15 + ______________________________ test_func[38] _______________________________ + /home/hpk/tmp/doc-exec-420/test_module.py:6: running the test CRASHED with signal 15 + =================== 3 failed, 47 passed in 3.41 seconds ==================== + +You'll see that a couple of tests are reported as crashing, indicated +by lower-case ``f`` and the respective failure summary. You can also use +the xdist-provided parallelization feature to speed up your testing:: + + $ py.test --boxed -n3 + =========================== test session starts ============================ + platform linux2 -- Python 2.7.3 -- pytest-2.3.0.dev8 + plugins: xdist, bugzilla, cache, oejskit, cli, pep8, cov + gw0 I / gw1 I / gw2 I + gw0 [50] / gw1 [50] / gw2 [50] + + scheduling tests via LoadScheduling + ..f...............f..................f............ + ================================= FAILURES ================================= + _______________________________ test_func[0] _______________________________ + [gw0] linux2 -- Python 2.7.3 /home/hpk/venv/1/bin/python + /home/hpk/tmp/doc-exec-420/test_module.py:6: running the test CRASHED with signal 15 + ______________________________ test_func[19] _______________________________ + [gw2] linux2 -- Python 2.7.3 /home/hpk/venv/1/bin/python + /home/hpk/tmp/doc-exec-420/test_module.py:6: running the test CRASHED with signal 15 + ______________________________ test_func[38] _______________________________ + [gw2] linux2 -- Python 2.7.3 /home/hpk/venv/1/bin/python + /home/hpk/tmp/doc-exec-420/test_module.py:6: running the test CRASHED with signal 15 + =================== 3 failed, 47 passed in 2.03 seconds ==================== https://bitbucket.org/hpk42/pytest-xdist/commits/59b574025218/ Changeset: 59b574025218 User: hpk42 Date: 2013-04-02 10:29:51 Summary: merge Affected #: 4 files diff -r d9fe8e544abfb630e9126c0d1a29ab9795c510d6 -r 59b574025218f112876c3b130dc353ddb8e433a5 setup.py --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="pytest-xdist", - version='1.8', + version='1.9dev1', description='py.test xdist plugin for distributed testing and loop-on-failing modes', long_description=open('README.txt').read(), license='GPLv2 or later', diff -r d9fe8e544abfb630e9126c0d1a29ab9795c510d6 -r 59b574025218f112876c3b130dc353ddb8e433a5 testing/test_remote.py --- a/testing/test_remote.py +++ b/testing/test_remote.py @@ -88,7 +88,7 @@ assert newrep.passed == rep.passed assert newrep.failed == rep.failed assert newrep.skipped == rep.skipped - if newrep.skipped and 'xfail' not in newrep.keywords: + if newrep.skipped and not hasattr(newrep, "wasxfail"): assert len(newrep.longrepr) == 3 assert newrep.outcome == rep.outcome assert newrep.when == rep.when diff -r d9fe8e544abfb630e9126c0d1a29ab9795c510d6 -r 59b574025218f112876c3b130dc353ddb8e433a5 testing/test_slavemanage.py --- a/testing/test_slavemanage.py +++ b/testing/test_slavemanage.py @@ -15,12 +15,14 @@ config = testdir.parseconfig() return config -class pytest_funcarg__mysetup: - def __init__(self, request): - temp = request.getfuncargvalue("tmpdir") - self.source = temp.mkdir("source") - self.dest = temp.mkdir("dest") - request.getfuncargvalue("_pytest") +def pytest_funcarg__mysetup(request): + class mysetup: + def __init__(self, request): + temp = request.getfuncargvalue("tmpdir") + self.source = temp.mkdir("source") + self.dest = temp.mkdir("dest") + request.getfuncargvalue("_pytest") + return mysetup(request) class TestNodeManagerPopen: def test_popen_no_default_chdir(self, config): @@ -97,11 +99,13 @@ call = hookrecorder.popcall("pytest_xdist_rsyncfinish") class TestHRSync: - class pytest_funcarg__mysetup: - def __init__(self, request): - tmp = request.getfuncargvalue('tmpdir') - self.source = tmp.mkdir("source") - self.dest = tmp.mkdir("dest") + def pytest_funcarg__mysetup(self, request): + class mysetup: + def __init__(self, request): + tmp = request.getfuncargvalue('tmpdir') + self.source = tmp.mkdir("source") + self.dest = tmp.mkdir("dest") + return mysetup(request) def test_hrsync_filter(self, mysetup): source, dest = mysetup.source, mysetup.dest diff -r d9fe8e544abfb630e9126c0d1a29ab9795c510d6 -r 59b574025218f112876c3b130dc353ddb8e433a5 xdist/__init__.py --- a/xdist/__init__.py +++ b/xdist/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '1.8' +__version__ = '1.9dev1' https://bitbucket.org/hpk42/pytest-xdist/commits/5e49f2b13ab6/ Changeset: 5e49f2b13ab6 User: hpk42 Date: 2013-04-02 10:30:52 Summary: merge again Affected #: 2 files diff -r 59b574025218f112876c3b130dc353ddb8e433a5 -r 5e49f2b13ab6fecf1e221131ea6d1efe5f73fab3 testing/test_looponfail.py --- a/testing/test_looponfail.py +++ b/testing/test_looponfail.py @@ -206,6 +206,24 @@ remotecontrol.loop_once() assert len(remotecontrol.failures) == 1 + def test_looponfail_multiple_errors(self, testdir, monkeypatch): + modcol = testdir.getmodulecol(""" + def test_one(): + assert 0 + """) + remotecontrol = RemoteControl(modcol.config) + orig_runsession = remotecontrol.runsession + + def runsession_dups(): + # twisted.trial test cases may report multiple errors. + failures, reports, collection_failed = orig_runsession() + print failures + return failures * 2, reports, collection_failed + + monkeypatch.setattr(remotecontrol, 'runsession', runsession_dups) + remotecontrol.loop_once() + assert len(remotecontrol.failures) == 1 + class TestFunctional: def test_fail_to_ok(self, testdir): diff -r 59b574025218f112876c3b130dc353ddb8e433a5 -r 5e49f2b13ab6fecf1e221131ea6d1efe5f73fab3 xdist/looponfail.py --- a/xdist/looponfail.py +++ b/xdist/looponfail.py @@ -89,7 +89,11 @@ if collection_failed: reports = ["Collection failed, keeping previous failure set"] else: - self.failures = failures + uniq_failures = [] + for failure in failures: + if failure not in uniq_failures: + uniq_failures.append(failure) + self.failures = uniq_failures def repr_pytest_looponfailinfo(failreports, rootdirs): tr = py.io.TerminalWriter() https://bitbucket.org/hpk42/pytest-xdist/commits/4bd2bb53ae3e/ Changeset: 4bd2bb53ae3e User: hpk42 Date: 2013-04-02 10:33:36 Summary: - changed LICENSE to MIT - attribute Jeremy's change Affected #: 3 files diff -r 5e49f2b13ab6fecf1e221131ea6d1efe5f73fab3 -r 4bd2bb53ae3e6d7c4f183f250ef291ebe90207b1 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +1.9.dev +------------------------- + +- changed LICENSE to MIT + +- fix duplicate reported test ids with --looponfailing + (thanks Jeremy Thurgood) + 1.8 ------------------------- diff -r 5e49f2b13ab6fecf1e221131ea6d1efe5f73fab3 -r 4bd2bb53ae3e6d7c4f183f250ef291ebe90207b1 LICENSE --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,19 @@ -The execnet package is released under the provisions of the Gnu Public -License (GPL), version 2 or later. -See http://www.fsf.org/licensing/licenses/ for more information. + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. -This package also contains some minor parts which -which are useable under the MIT license. - -If you have questions and/or want to use parts of -the code under a different license than the GPL -please contact me. - -holger krekel, January 2010, holger at merlinux eu diff -r 5e49f2b13ab6fecf1e221131ea6d1efe5f73fab3 -r 4bd2bb53ae3e6d7c4f183f250ef291ebe90207b1 setup.py --- a/setup.py +++ b/setup.py @@ -5,9 +5,9 @@ version='1.9dev1', description='py.test xdist plugin for distributed testing and loop-on-failing modes', long_description=open('README.txt').read(), - license='GPLv2 or later', + license='MIT', author='holger krekel and contributors', - author_email='py-dev at codespeak.net,holger at merlinux.eu', + author_email='pytest-dev at python.org,holger at merlinux.eu', url='http://bitbucket.org/hpk42/pytest-xdist', platforms=['linux', 'osx', 'win32'], packages = ['xdist'], @@ -17,7 +17,7 @@ classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', - 'License :: OSI Approved :: GNU General Public License (GPL)', + 'License :: OSI Approved :: MIT License', 'Operating System :: POSIX', 'Operating System :: Microsoft :: Windows', 'Operating System :: MacOS :: MacOS X', Repository URL: https://bitbucket.org/hpk42/pytest-xdist/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. From commits-noreply at bitbucket.org Tue Apr 2 10:48:36 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 02 Apr 2013 08:48:36 -0000 Subject: [Pytest-commit] commit/pytest-xdist: hpk42: fix py3 issue Message-ID: <20130402084836.32031.67604@bitbucket21.managed.contegix.com> 1 new commit in pytest-xdist: https://bitbucket.org/hpk42/pytest-xdist/commits/d12d4048a36d/ Changeset: d12d4048a36d User: hpk42 Date: 2013-04-02 10:48:26 Summary: fix py3 issue Affected #: 1 file diff -r 4bd2bb53ae3e6d7c4f183f250ef291ebe90207b1 -r d12d4048a36df7189d44382d2b83d7af098bf35c testing/test_looponfail.py --- a/testing/test_looponfail.py +++ b/testing/test_looponfail.py @@ -217,7 +217,7 @@ def runsession_dups(): # twisted.trial test cases may report multiple errors. failures, reports, collection_failed = orig_runsession() - print failures + print (failures) return failures * 2, reports, collection_failed monkeypatch.setattr(remotecontrol, 'runsession', runsession_dups) Repository URL: https://bitbucket.org/hpk42/pytest-xdist/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. From commits-noreply at bitbucket.org Wed Apr 3 22:23:28 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Wed, 03 Apr 2013 20:23:28 -0000 Subject: [Pytest-commit] commit/pytest: sashahart: doc fix: 'x' should be '-x' so it is not interpreted as a filename Message-ID: <20130403202328.5457.57939@bitbucket13.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/6fb2ae923e2d/ Changeset: 6fb2ae923e2d User: sashahart Date: 2013-04-03 21:51:06 Summary: doc fix: 'x' should be '-x' so it is not interpreted as a filename Affected #: 2 files diff -r 7697ae2f476df2bbc3bf65006abb1ff9f11d1664 -r 6fb2ae923e2df3cc9aaf5e696c8fee1113893d3a doc/en/usage.txt --- a/doc/en/usage.txt +++ b/doc/en/usage.txt @@ -165,7 +165,7 @@ It will not raise ``SystemExit`` but return the exitcode instead. You can pass in options and arguments:: - pytest.main(['x', 'mytestdir']) + pytest.main(['-x', 'mytestdir']) or pass in a string:: diff -r 7697ae2f476df2bbc3bf65006abb1ff9f11d1664 -r 6fb2ae923e2df3cc9aaf5e696c8fee1113893d3a doc/ja/usage.txt --- a/doc/ja/usage.txt +++ b/doc/ja/usage.txt @@ -276,7 +276,7 @@ ???????????? "py.test" ?????????????? ``SystemExit`` ????????????????????????????????????????:: - pytest.main(['x', 'mytestdir']) + pytest.main(['-x', 'mytestdir']) .. or pass in a string:: 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. From issues-reply at bitbucket.org Thu Apr 4 07:24:23 2013 From: issues-reply at bitbucket.org (Torsten Landschoff) Date: Thu, 04 Apr 2013 05:24:23 -0000 Subject: [Pytest-commit] [hpk42/pytest] Pass test result to finalizer for cleaning up debug data (issue #288) Message-ID: <20130404052423.11905.29703@bitbucket16.managed.contegix.com> New issue 288: Pass test result to finalizer for cleaning up debug data https://bitbucket.org/hpk42/pytest/issue/288/pass-test-result-to-finalizer-for-cleaning Torsten Landschoff: We are currently juggling with big files in tests which we currently store in tmpdir. This kills our Jenkins slaves because py.test will keep temporary files for 3 runs of each test suite. We are no up at > 10GB of temporary files for some projects per test run. Keeping the temporary files is indeed a nice feature which we often use during TDD to find out what we were missing. But the temporary files of a passed test are 99.99% worthless for us. Therefore I'd like to have a tmpdir fixture that cleans up the temporary files if the test was successful or skipped. Or have some options to configure how py.test handles temporary files wrt. what is kept. As an intermediate step I am currently moving some pytest.fixture functions to clean up the temporary files after use, but I end up removing the files even if the test failed. What I am also just realizing: We moved the temporary files inside the Jenkins workspace of each project to keep track of disk usage and for easy access via the web interface. If only temporary files for failed tests are kept, then we could archive them as build artifacts so that we can even diagnose tests that failed in the past. I was thinking about something in the line of ``` #!python @pytest.fixture def database(request): # Pull SQLite test database from somewhere dbfile = "..." def finalizer(testresult): if testresult == "PASS": os.unlink(dbfile) request.addfinalizer(finalizer, parameters=["testresult"]) ``` Alternatively, pytest could use introspection to inject the testresult if the finalizer takes a testresult argument. -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From commits-noreply at bitbucket.org Thu Apr 4 14:36:52 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Thu, 04 Apr 2013 12:36:52 -0000 Subject: [Pytest-commit] commit/pytest: hpk42: fix reference Message-ID: <20130404123652.7667.75649@bitbucket15.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/82139da07b58/ Changeset: 82139da07b58 User: hpk42 Date: 2013-04-04 14:36:44 Summary: fix reference Affected #: 1 file diff -r 6fb2ae923e2df3cc9aaf5e696c8fee1113893d3a -r 82139da07b58da52fc124be4218c8957b71f3ac1 doc/en/fixture.txt --- a/doc/en/fixture.txt +++ b/doc/en/fixture.txt @@ -298,7 +298,6 @@ > assert 0, smtp.helo() E AssertionError: (250, 'mail.python.org') -.. _`request`: :py:class:`_pytest.python.FixtureRequest` .. _`fixture-parametrize`: @@ -315,7 +314,7 @@ Extending the previous example, we can flag the fixture to create two ``smtp`` fixture instances which will cause all tests using the fixture to run twice. The fixture function gets access to each parameter -through the special `request`_ object:: +through the special :py:class:`request ` object:: # content of conftest.py import pytest 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. From issues-reply at bitbucket.org Thu Apr 4 15:05:02 2013 From: issues-reply at bitbucket.org (Tom Willis) Date: Thu, 04 Apr 2013 13:05:02 -0000 Subject: [Pytest-commit] [hpk42/pytest] buildout + py.test + xdist (issue #289) Message-ID: <20130404130502.5617.82398@bitbucket02.managed.contegix.com> New issue 289: buildout + py.test + xdist https://bitbucket.org/hpk42/pytest/issue/289/buildout-pytest-xdist Tom Willis: we have an appengine project that we unit test with py.test and I would love to get it running things in parallel if possible. I hate to call this a bug, because I just don't know, but the tracker won't let me assign anything closer to appropriate. After installing py.test and xdist in buildout... (development *) twillis at hello-kitty:~/projects/buttercup_dev$ ./bin/py.test -n8 src/hydrant-app/tests/integration/ ===================================================================================================================================================== test session starts ===================================================================================================================================================== platform linux2 -- Python 2.7.3 -- pytest-2.3.4 plugins: cov, xdist gw0 C / gw1 C / gw2 C / gw3 C / gw4 C / gw5 C / gw6 C / gw7 C[gw0] node down: Traceback (most recent call last): File "/home/twillis/.buildout/eggs/execnet-1.1-py2.7.egg/execnet/gateway_base.py", line 800, in executetask do_exec(co, loc) File "", line 1, in do_exec File "", line 134, in ImportError: No module named py if I instead install pytest and pytest-xdist in my system python distribution I have to add ./ext to PYTHON_PATH which is a place where all libs are symlinked to make it easier for my editor to find the source. (development *) twillis at hello-kitty:~/projects/buttercup_dev$ PYTHON_PATH=./ext:$PYTHON_PATH py.test -n8 src/hydrant-app/tests/integration/test_account.py ===================================================================================================================================================== test session starts ===================================================================================================================================================== platform linux2 -- Python 2.7.3 -- pytest-2.3.4 plugins: xdist, cov gw0 [0] / gw1 [0] / gw2 [0] / gw3 [0] / gw4 [0] / gw5 [0] / gw6 [0] / gw7 [0] scheduling tests via LoadScheduling ====================================================================================================================================================== in 0.48 seconds ======================================================================================================================================================= so no error, but my tests don't run. attached is the py.test script generated by buildout which has all the paths our buildout environment requires. any ideas? -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From issues-reply at bitbucket.org Thu Apr 4 16:20:00 2013 From: issues-reply at bitbucket.org (aheld84) Date: Thu, 04 Apr 2013 14:20:00 -0000 Subject: [Pytest-commit] [hpk42/tox] envsitepackagesdir is not expanded correctly (issue #92) Message-ID: <20130404142000.21858.48189@bitbucket15.managed.contegix.com> New issue 92: envsitepackagesdir is not expanded correctly https://bitbucket.org/hpk42/tox/issue/92/envsitepackagesdir-is-not-expanded aheld84: The `{envsitepackagesdir}` is not expanded correctly. For the following _tox.ini_ ``` #!configfile [testenv] deps = pytest commands = py.test --junitxml=junit-{envname}.xml {envsitepackagesdir}/foo ``` I get this output from jenkins: ``` #!bash ============================= test session starts ============================== platform linux2 -- Python 2.7.3 -- pytest-2.3.4 ERROR: file not found: >/foo =============================== in 0.00 seconds =============================== ERROR: InvocationError: '/var/lib/jenkins/jobs/foo/workspace/TOXENV/py27/src/foo/.tox/py27/bin/py.test --junitxml=junit-py27.xml >/foo' ___________________________________ summary ____________________________________ ERROR: py27: commands failed ``` Maybe a missing `@property` ? -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From commits-noreply at bitbucket.org Fri Apr 5 22:44:56 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Fri, 05 Apr 2013 20:44:56 -0000 Subject: [Pytest-commit] commit/tox: 2 new changesets Message-ID: <20130405204456.3914.93414@bitbucket05.managed.contegix.com> 2 new commits in tox: https://bitbucket.org/hpk42/tox/commits/b0f2d6e1ddd5/ Changeset: b0f2d6e1ddd5 User: hpk42 Date: 2013-04-05 22:16:39 Summary: doc fixes Affected #: 2 files diff -r 251c2898360aa903bf6126dbcc364063e2a9d6b5 -r b0f2d6e1ddd57070701a31365f4dc0344846c2d7 doc/conf.py --- a/doc/conf.py +++ b/doc/conf.py @@ -41,7 +41,7 @@ # General information about the project. project = u'tox' -copyright = u'2011, holger krekel and others' +copyright = u'2013, holger krekel and others' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff -r 251c2898360aa903bf6126dbcc364063e2a9d6b5 -r b0f2d6e1ddd57070701a31365f4dc0344846c2d7 doc/index.txt --- a/doc/index.txt +++ b/doc/index.txt @@ -1,7 +1,7 @@ Welcome to the tox automation project =============================================== -.. note:: Upcoming: `professional testing with pytest and tox <`http://www.python-academy.com/courses/specialtopics/python_course_testing.html>`_ , 24th-26th June 2013, Leipzig. +.. note:: Upcoming: `professional testing with pytest and tox `_ , 24th-26th June 2013, Leipzig. vision: standardize testing in Python --------------------------------------------- https://bitbucket.org/hpk42/tox/commits/2bedb02425da/ Changeset: 2bedb02425da User: hpk42 Date: 2013-04-05 22:44:32 Summary: fix issue92 envsitepackagesdir to work correctly. Also fix the test. Affected #: 6 files diff -r b0f2d6e1ddd57070701a31365f4dc0344846c2d7 -r 2bedb02425da0785e6fab7a663bece85dc498299 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ 1.5.0.dev ----------------- +- fix issue92 - fix {envsitepackagesdir} to actually work again + - re-license tox to MIT license - depend on virtualenv-1.9.1 diff -r b0f2d6e1ddd57070701a31365f4dc0344846c2d7 -r 2bedb02425da0785e6fab7a663bece85dc498299 setup.py --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ description='virtualenv-based automation of test activities', long_description=long_description, url='http://tox.testrun.org/', - version='1.5.0.dev1', + version='1.5.dev6', license='http://opensource.org/licenses/MIT', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], author='holger krekel', diff -r b0f2d6e1ddd57070701a31365f4dc0344846c2d7 -r 2bedb02425da0785e6fab7a663bece85dc498299 tests/test_z_cmdline.py --- a/tests/test_z_cmdline.py +++ b/tests/test_z_cmdline.py @@ -448,12 +448,16 @@ sdist_path = session.sdist() assert sdist_path == p - at pytest.mark.xfailif("sys.platform == 'win32'") + at pytest.mark.xfail("sys.platform == 'win32'", reason="test needs better impl") def test_envsitepackagesdir(cmd, initproj): initproj("pkg512-0.0.5", filedefs={ 'tox.ini': """ + [testenv] commands= - grep '__version__.*=.*0\.0\.5' {envsitepackagesdir}/pkg512/__init__.py + echo X:{envsitepackagesdir} """}) result = cmd.run("tox") - + assert result.ret == 0 + result.stdout.fnmatch_lines(""" + X:*site-packages* + """) diff -r b0f2d6e1ddd57070701a31365f4dc0344846c2d7 -r 2bedb02425da0785e6fab7a663bece85dc498299 tox/__init__.py --- a/tox/__init__.py +++ b/tox/__init__.py @@ -1,5 +1,5 @@ # -__version__ = '1.5.0.dev1' +__version__ = '1.5.dev6' class exception: class Error(Exception): diff -r b0f2d6e1ddd57070701a31365f4dc0344846c2d7 -r 2bedb02425da0785e6fab7a663bece85dc498299 tox/_config.py --- a/tox/_config.py +++ b/tox/_config.py @@ -128,6 +128,7 @@ name = "python" return self.envbindir.join(name) + # no @property to avoid early calling (see callable(subst[key]) checks) def envsitepackagesdir(self): print_envsitepackagesdir = textwrap.dedent(""" import sys @@ -490,7 +491,7 @@ raise tox.exception.ConfigError( "substitution key %r not found" % key) - if py.builtin.callable(val): + elif py.builtin.callable(val): val = val() return str(val) @@ -527,7 +528,10 @@ if sub_key not in self._subs: raise tox.exception.ConfigError( "substitution key %r not found" % sub_key) - return '"%s"' % str(self._subs[sub_key]).replace('"', r'\"') + val = self._subs[sub_key] + if py.builtin.callable(val): + val = val() + return '"%s"' % str(val).replace('"', r'\"') def _is_bare_posargs(self, groupdict): return groupdict.get('substitution_value', None) == 'posargs' \ diff -r b0f2d6e1ddd57070701a31365f4dc0344846c2d7 -r 2bedb02425da0785e6fab7a663bece85dc498299 toxbootstrap.py --- a/toxbootstrap.py +++ b/toxbootstrap.py @@ -58,7 +58,7 @@ """ -__version__ = '1.4.3.dev6' +__version__ = '1.5.0.dev2' import sys import os Repository URL: https://bitbucket.org/hpk42/tox/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. From commits-noreply at bitbucket.org Sat Apr 6 10:25:30 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Sat, 06 Apr 2013 08:25:30 -0000 Subject: [Pytest-commit] commit/tox: asmundg: Test that envsitepackagesdir actually gets called Message-ID: <20130406082530.4977.17637@bitbucket05.managed.contegix.com> 1 new commit in tox: https://bitbucket.org/hpk42/tox/commits/1b8bdf9ab87e/ Changeset: 1b8bdf9ab87e User: asmundg Date: 2013-04-06 10:17:58 Summary: Test that envsitepackagesdir actually gets called It's hard to check that the system integration part is correct without reimplementing it in the test, but we can at least see if the method gets called and doesn't crash. Affected #: 1 file diff -r 2bedb02425da0785e6fab7a663bece85dc498299 -r 1b8bdf9ab87e87203df8543b8e5a85bc30433f52 tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,6 +1,7 @@ import tox import pytest import os, sys +import subprocess from textwrap import dedent import py @@ -590,6 +591,35 @@ assert conf.changedir.basename == 'testing' assert conf.changedir.dirpath().realpath() == tmpdir.realpath() + @pytest.mark.xfailif("sys.platform == 'win32'") + def test_substitution_envsitepackagesdir(self, tmpdir, monkeypatch, + newconfig): + """ + The envsitepackagesdir property is mostly doing system work, + so this test doesn't excercise it very well. + + Usage of envsitepackagesdir on win32/jython will explicitly + throw an exception, + """ + class MockPopen(object): + returncode = 0 + + def __init__(self, *args, **kwargs): + pass + + def communicate(self, *args, **kwargs): + return 'onevalue', 'othervalue' + + monkeypatch.setattr(subprocess, 'Popen', MockPopen) + env = 'py%s' % (''.join(sys.version.split('.')[0:2])) + config = newconfig(""" + [testenv:%s] + commands = {envsitepackagesdir} + """ % (env)) + conf = config.envconfigs[env] + argv = conf.commands + assert argv[0][0] == 'onevalue' + class TestGlobalOptions: def test_notest(self, newconfig): Repository URL: https://bitbucket.org/hpk42/tox/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. From issues-reply at bitbucket.org Sun Apr 7 19:28:22 2013 From: issues-reply at bitbucket.org (Anonymous) Date: Sun, 07 Apr 2013 17:28:22 -0000 Subject: [Pytest-commit] [hpk42/pytest] Exception when the fixture is parametrized twice with the same value (issue #290) Message-ID: <20130407172822.24836.71952@bitbucket04.managed.contegix.com> New issue 290: Exception when the fixture is parametrized twice with the same value https://bitbucket.org/hpk42/pytest/issue/290/exception-when-the-fixture-is-parametrized Anonymous: import pytest @pytest.fixture(params=['a', 'a']) def foo(request): return request.param def test_foo(foo): pass I will get an exception KeyError: 'foo'. I understand that the same value maybe doesn't sound like good idea, but i'm writing a plugin for pytest and testing the side effect of the multiple run. Responsible: hpk42 -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From issues-reply at bitbucket.org Mon Apr 8 07:21:15 2013 From: issues-reply at bitbucket.org (Torsten Landschoff) Date: Mon, 08 Apr 2013 05:21:15 -0000 Subject: [Pytest-commit] [hpk42/pytest] tmpdir names get too long on Windows (exceeding PATH_MAX) (issue #291) Message-ID: <20130408052115.30219.56185@bitbucket16.managed.contegix.com> New issue 291: tmpdir names get too long on Windows (exceeding PATH_MAX) https://bitbucket.org/hpk42/pytest/issue/291/tmpdir-names-get-too-long-on-windows Torsten Landschoff: Hi pytest Team, we run into a lot of error in our release tests lately, which do not occur in nightly an on-commit tests. Looking into this, I discovered that path names get too long when we are using tmpdir: c:\users\dynamore\appdata\local\temp\pytest-21\test_change_own_private_components_public_incoming_conflict_pull_C__jenkins_workspace_loco2_win7_32_client_release_testdata_testdb_dump_0\vaultdir\zipped\00\005292e500e4e76be18e798eccee423dec2e24c57db4b030348e67a7 On (german) Windows this results into WindowsError: [Error 3] Das System kann den angegebenen Pfad nicht finden which would point to a bug in our implementation. It is unobvious to me that tmpdir includes the following info in the path: * the full function name * the parameters of the test call (full path to testdb.dump over here) This can make the temporary path arbitrary long which causes problems on Windows. I think, py.test should shorten the path automatically (at least on Windows). We can work around this by passing relative filenames (less robust in case the code does a chdir, but that would break other tests anyway) and by shorting the names of our test functions. However, I would like to keep the test function names expressive. -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From issues-reply at bitbucket.org Wed Apr 10 06:35:20 2013 From: issues-reply at bitbucket.org (Nikolaus Rath) Date: Wed, 10 Apr 2013 04:35:20 -0000 Subject: [Pytest-commit] [hpk42/pytest] Files created with tempfile.NamedTemporaryFile() are not automatically removed when running under test.py (issue #292) Message-ID: <20130410043520.24676.21888@bitbucket16.managed.contegix.com> New issue 292: Files created with tempfile.NamedTemporaryFile() are not automatically removed when running under test.py https://bitbucket.org/hpk42/pytest/issue/292/files-created-with Nikolaus Rath: When using tempfile.NamedTemporaryFile() while running under py.test, the automatic deletion of the file is somehow prevented. Testcase: ``` #!sh $ cat test.py from __future__ import division, print_function, absolute_import import tempfile import unittest2 as unittest class cache_tests(unittest.TestCase): def setUp(self): self.dbfile = tempfile.NamedTemporaryFile(prefix='s3qldb_') def test_get(self): self.assertEqual('foo', 'foo') $ ls /tmp/s3qldb* /bin/ls: cannot access /tmp/s3qldb*: No such file or directory $ py.test test.py ============ test session starts ============ platform linux2 -- Python 2.7.3 -- pytest-2.2.4 collected 1 items test.py . ============ 1 passed in 0.01 seconds ============ $ ls /tmp/s3qldb* /tmp/s3qldb_ZKhwhz ``` -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From issues-reply at bitbucket.org Thu Apr 11 22:28:47 2013 From: issues-reply at bitbucket.org (Oleg Pidsadnyi) Date: Thu, 11 Apr 2013 20:28:47 -0000 Subject: [Pytest-commit] [hpk42/pytest] When fixture has the same parameter value it crashes for me with KeyError (issue #293) Message-ID: <20130411202847.25476.78595@bitbucket24.managed.contegix.com> New issue 293: When fixture has the same parameter value it crashes for me with KeyError https://bitbucket.org/hpk42/pytest/issue/293/when-fixture-has-the-same-parameter-value Oleg Pidsadnyi: KeyError: foo ``` #!python import pytest @pytest.fixture(params=['a', 'a']) def foo(request): return request.param def test_foo(foo): pass ``` -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From issues-reply at bitbucket.org Thu Apr 11 22:35:43 2013 From: issues-reply at bitbucket.org (Oleg Pidsadnyi) Date: Thu, 11 Apr 2013 20:35:43 -0000 Subject: [Pytest-commit] [hpk42/pytest] Fixture is not overriden in the child conftest.py when running individual test file (issue #294) Message-ID: <20130411203543.420.2526@bitbucket13.managed.contegix.com> New issue 294: Fixture is not overriden in the child conftest.py when running individual test file https://bitbucket.org/hpk42/pytest/issue/294/fixture-is-not-overriden-in-the-child Oleg Pidsadnyi: If I have the package with the conftest.py: ``` #!python from pytest import fixture def foo(): return 'parent' ``` And I have subfolder with conftest.py: ``` #!python from pytest import fixture def foo(): return 'child' ``` And the test_foo.py in the same subfolder: ``` #!python def test_foo(foo): assert foo == 'child' ``` It works when I simply run py.test. It doesn't work when I run py.test subfolder/test_foo.py For some reason the value is 'parent', not 'child' -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. From issues-reply at bitbucket.org Fri Apr 12 08:32:22 2013 From: issues-reply at bitbucket.org (Alexander Dupuy) Date: Fri, 12 Apr 2013 06:32:22 -0000 Subject: [Pytest-commit] [hpk42/pytest] in docs, recwarn.txt lacks any :ref: targets (issue #297) Message-ID: <20130412063222.9854.55860@bitbucket23.managed.contegix.com> New issue 297: in docs, recwarn.txt lacks any :ref: targets https://bitbucket.org/hpk42/pytest/issue/297/in-docs-recwarntxt-lacks-any-ref-targets Alexander Dupuy: Whereas skipping.txt has several targets, e.g.: .. _`skip and xfail`: .. _skipping: at the start of the file, with others as well, there are no targets at all in recwarn.txt, so it isn't possible to use intersphinx :ref: links to this documentation. From issues-reply at bitbucket.org Fri Apr 12 15:27:54 2013 From: issues-reply at bitbucket.org (florian_bauer) Date: Fri, 12 Apr 2013 13:27:54 -0000 Subject: [Pytest-commit] [hpk42/pytest] pytester.TmpTestdir._run breaks on Python3.3 / Windows for unicode output (issue #298) Message-ID: <20130412132754.30602.37077@bitbucket25.managed.contegix.com> New issue 298: pytester.TmpTestdir._run breaks on Python3.3 / Windows for unicode output https://bitbucket.org/hpk42/pytest/issue/298/pytestertmptestdir_run-breaks-on-python33 florian_bauer: Hi, I noticed that pytester.TmpTestdir._run does fail with a UnicodeDecodeError on Python 3, if a test uses the testdir fixture and generates non-ascii output. At least on my windows, sys.getfilesystemencoding() returns 'mbcs', not 'utf8'. Attached is a file with two testcases. test_unicode() fails for me, whereas test_unicode_patched shows my local workaround. Unfortunately I can't work on a proper patch right now, but the only change required is to replace the hard-coded 'utf8' encoding with the output of sys.getfilesystemencoding() From issues-reply at bitbucket.org Fri Apr 12 17:28:42 2013 From: issues-reply at bitbucket.org (Floris Bruynooghe) Date: Fri, 12 Apr 2013 15:28:42 -0000 Subject: [Pytest-commit] [hpk42/pytest] --tb option does not affect tracebacks in test setup (issue #299) Message-ID: <20130412152842.23483.54422@bitbucket03.managed.contegix.com> New issue 299: --tb option does not affect tracebacks in test setup https://bitbucket.org/hpk42/pytest/issue/299/tb-option-does-not-affect-tracebacks-in Floris Bruynooghe: It appears the --tb option is not respected when the error occurs during setup (and presumably teardown) of a test. I'm not even sure if it should, but I did find it slightly surprising. From issues-reply at bitbucket.org Mon Apr 15 22:07:45 2013 From: issues-reply at bitbucket.org (Takafumi Arakaki) Date: Mon, 15 Apr 2013 20:07:45 -0000 Subject: [Pytest-commit] [hpk42/tox] Environment is not recreated when install_requires in setup.py is changed (issue #93) Message-ID: <20130415200745.16749.62776@bitbucket24.managed.contegix.com> New issue 93: Environment is not recreated when install_requires in setup.py is changed https://bitbucket.org/hpk42/tox/issue/93/environment-is-not-recreated-when Takafumi Arakaki: Here is a recipe to reproduce this problem. 1. Run tox in some project. 2. Add a new package to install_requires in setup.py 3. Run tox again. I can write dependency in tox.ini to force recreate, but I think it is simpler if tox reinstall package. I think it is as easy as removing --no-deps flag so I wonder why --no-deps is used in the first place. Is there any drawbacks? Wouldn't it be nice if we can disable this flag optionally? From commits-noreply at bitbucket.org Tue Apr 16 08:47:29 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 16 Apr 2013 06:47:29 -0000 Subject: [Pytest-commit] commit/pytest: RonnyPfannschmidt: move pdb plugin post morten traceback selection to a own function Message-ID: <20130416064729.31757.55025@bitbucket22.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/1e37dc2b23fe/ Changeset: 1e37dc2b23fe User: RonnyPfannschmidt Date: 2013-04-16 08:46:55 Summary: move pdb plugin post morten traceback selection to a own function this is preparation for making it resillent against broken envs that can't import doctest Affected #: 1 file diff -r 82139da07b58da52fc124be4218c8957b71f3ac1 -r 1e37dc2b23fe92b81da6be1c4b6bde2025ee4f1b _pytest/pdb.py --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -70,16 +70,21 @@ tw.sep(">", "traceback") rep.toterminal(tw) tw.sep(">", "entering PDB") - # A doctest.UnexpectedException is not useful for post_mortem. - # Use the underlying exception instead: - if isinstance(call.excinfo.value, py.std.doctest.UnexpectedException): - tb = call.excinfo.value.exc_info[2] - else: - tb = call.excinfo._excinfo[2] + + tb = self._postmortem_traceback(call.excinfo) post_mortem(tb) rep._pdbshown = True return rep + @staticmethod + def _postmortem_traceback(excinfo): + # A doctest.UnexpectedException is not useful for post_mortem. + # Use the underlying exception instead: + if isinstance(excinfo.value, py.std.doctest.UnexpectedException): + return excinfo.value.exc_info[2] + else: + return excinfo._excinfo[2] + def post_mortem(t): pdb = py.std.pdb class Pdb(pdb.Pdb): 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. From commits-noreply at bitbucket.org Tue Apr 16 09:02:12 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 16 Apr 2013 07:02:12 -0000 Subject: [Pytest-commit] commit/pytest: 2 new changesets Message-ID: <20130416070212.24617.66582@bitbucket15.managed.contegix.com> 2 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/69543636b13a/ Changeset: 69543636b13a User: adamgoucher Date: 2013-04-16 06:45:14 Summary: stdout/stderr now captured by junitxml Affected #: 3 files diff -r 82139da07b58da52fc124be4218c8957b71f3ac1 -r 69543636b13a1e2cad7e9296b0b69d6b785577fb _pytest/capture.py --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -173,8 +173,7 @@ if funcarg_outerr is not None: outerr = (outerr[0] + funcarg_outerr[0], outerr[1] + funcarg_outerr[1]) - if not rep.passed: - addouterr(rep, outerr) + addouterr(rep, outerr) if not rep.passed or rep.when == "teardown": outerr = ('', '') item.outerr = outerr diff -r 82139da07b58da52fc124be4218c8957b71f3ac1 -r 69543636b13a1e2cad7e9296b0b69d6b785577fb _pytest/junitxml.py --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -107,11 +107,20 @@ time=getattr(report, 'duration', 0) )) + def _write_captured_output(self, report): + sec = dict(report.sections) + for name in ('out', 'err'): + content = sec.get("Captured std%s" % name) + if content: + tag = getattr(Junit, 'system-'+name) + self.append(tag(bin_xml_escape(content))) + def append(self, obj): self.tests[-1].append(obj) def append_pass(self, report): self.passed += 1 + self._write_captured_output(report) def append_failure(self, report): #msg = str(report.longrepr.reprtraceback.extraline) @@ -120,16 +129,11 @@ Junit.skipped(message="xfail-marked test passes unexpectedly")) self.skipped += 1 else: - sec = dict(report.sections) fail = Junit.failure(message="test failure") fail.append(str(report.longrepr)) self.append(fail) - for name in ('out', 'err'): - content = sec.get("Captured std%s" % name) - if content: - tag = getattr(Junit, 'system-'+name) - self.append(tag(bin_xml_escape(content))) self.failed += 1 + self._write_captured_output(report) def append_collect_failure(self, report): #msg = str(report.longrepr.reprtraceback.extraline) @@ -162,6 +166,7 @@ message=skipreason )) self.skipped += 1 + self._write_captured_output(report) def pytest_runtest_logreport(self, report): if report.passed: diff -r 82139da07b58da52fc124be4218c8957b71f3ac1 -r 69543636b13a1e2cad7e9296b0b69d6b785577fb testing/test_junitxml.py --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -282,13 +282,35 @@ if not sys.platform.startswith("java"): assert "hx" in fnode.toxml() + def test_pass_captures_stdout(self, testdir): + testdir.makepyfile(""" + def test_pass(): + print('hello-stdout') + """) + result, dom = runandparse(testdir) + node = dom.getElementsByTagName("testsuite")[0] + pnode = node.getElementsByTagName("testcase")[0] + systemout = pnode.getElementsByTagName("system-out")[0] + assert "hello-stdout" in systemout.toxml() + + def test_pass_captures_stderr(self, testdir): + testdir.makepyfile(""" + import sys + def test_pass(): + sys.stderr.write('hello-stderr') + """) + result, dom = runandparse(testdir) + node = dom.getElementsByTagName("testsuite")[0] + pnode = node.getElementsByTagName("testcase")[0] + systemout = pnode.getElementsByTagName("system-err")[0] + assert "hello-stderr" in systemout.toxml() + def test_mangle_testnames(): from _pytest.junitxml import mangle_testnames names = ["a/pything.py", "Class", "()", "method"] newnames = mangle_testnames(names) assert newnames == ["a.pything", "Class", "method"] - def test_dont_configure_on_slaves(tmpdir): gotten = [] class FakeConfig: https://bitbucket.org/hpk42/pytest/commits/a8b625d3000c/ Changeset: a8b625d3000c User: hpk42 Date: 2013-04-16 09:02:08 Summary: Merged in adamgoucher/pytest (pull request #29) stdout/stderr now captured by junitxml Affected #: 3 files diff -r 1e37dc2b23fe92b81da6be1c4b6bde2025ee4f1b -r a8b625d3000c8048a9630d6bf8dc45bdabc44a9a _pytest/capture.py --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -173,8 +173,7 @@ if funcarg_outerr is not None: outerr = (outerr[0] + funcarg_outerr[0], outerr[1] + funcarg_outerr[1]) - if not rep.passed: - addouterr(rep, outerr) + addouterr(rep, outerr) if not rep.passed or rep.when == "teardown": outerr = ('', '') item.outerr = outerr diff -r 1e37dc2b23fe92b81da6be1c4b6bde2025ee4f1b -r a8b625d3000c8048a9630d6bf8dc45bdabc44a9a _pytest/junitxml.py --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -107,11 +107,20 @@ time=getattr(report, 'duration', 0) )) + def _write_captured_output(self, report): + sec = dict(report.sections) + for name in ('out', 'err'): + content = sec.get("Captured std%s" % name) + if content: + tag = getattr(Junit, 'system-'+name) + self.append(tag(bin_xml_escape(content))) + def append(self, obj): self.tests[-1].append(obj) def append_pass(self, report): self.passed += 1 + self._write_captured_output(report) def append_failure(self, report): #msg = str(report.longrepr.reprtraceback.extraline) @@ -120,16 +129,11 @@ Junit.skipped(message="xfail-marked test passes unexpectedly")) self.skipped += 1 else: - sec = dict(report.sections) fail = Junit.failure(message="test failure") fail.append(str(report.longrepr)) self.append(fail) - for name in ('out', 'err'): - content = sec.get("Captured std%s" % name) - if content: - tag = getattr(Junit, 'system-'+name) - self.append(tag(bin_xml_escape(content))) self.failed += 1 + self._write_captured_output(report) def append_collect_failure(self, report): #msg = str(report.longrepr.reprtraceback.extraline) @@ -162,6 +166,7 @@ message=skipreason )) self.skipped += 1 + self._write_captured_output(report) def pytest_runtest_logreport(self, report): if report.passed: diff -r 1e37dc2b23fe92b81da6be1c4b6bde2025ee4f1b -r a8b625d3000c8048a9630d6bf8dc45bdabc44a9a testing/test_junitxml.py --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -282,13 +282,35 @@ if not sys.platform.startswith("java"): assert "hx" in fnode.toxml() + def test_pass_captures_stdout(self, testdir): + testdir.makepyfile(""" + def test_pass(): + print('hello-stdout') + """) + result, dom = runandparse(testdir) + node = dom.getElementsByTagName("testsuite")[0] + pnode = node.getElementsByTagName("testcase")[0] + systemout = pnode.getElementsByTagName("system-out")[0] + assert "hello-stdout" in systemout.toxml() + + def test_pass_captures_stderr(self, testdir): + testdir.makepyfile(""" + import sys + def test_pass(): + sys.stderr.write('hello-stderr') + """) + result, dom = runandparse(testdir) + node = dom.getElementsByTagName("testsuite")[0] + pnode = node.getElementsByTagName("testcase")[0] + systemout = pnode.getElementsByTagName("system-err")[0] + assert "hello-stderr" in systemout.toxml() + def test_mangle_testnames(): from _pytest.junitxml import mangle_testnames names = ["a/pything.py", "Class", "()", "method"] newnames = mangle_testnames(names) assert newnames == ["a.pything", "Class", "method"] - def test_dont_configure_on_slaves(tmpdir): gotten = [] class FakeConfig: 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. From commits-noreply at bitbucket.org Tue Apr 16 09:14:59 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 16 Apr 2013 07:14:59 -0000 Subject: [Pytest-commit] commit/pytest: 3 new changesets Message-ID: <20130416071459.9969.12503@bitbucket03.managed.contegix.com> 3 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/5d9007722ea1/ Changeset: 5d9007722ea1 User: hpk42 Date: 2013-04-16 09:04:05 Summary: slightly improve -k help string cosmetic change to test_nose.py Affected #: 2 files diff -r 82139da07b58da52fc124be4218c8957b71f3ac1 -r 5d9007722ea163f43d4115f76a72cfd527111cbd _pytest/mark.py --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -7,8 +7,8 @@ def pytest_addoption(parser): group = parser.getgroup("general") group._addoption('-k', - action="store", dest="keyword", default='', metavar="KEYWORDEXPR", - help="only run tests which match the given expression. " + action="store", dest="keyword", default='', metavar="EXPRESSION", + help="only run tests which match the given substring expression. " "An expression is a python evaluatable expression " "where all names are substring-matched against test names " "and keywords. Example: -k 'test_method or test_other' " diff -r 82139da07b58da52fc124be4218c8957b71f3ac1 -r 5d9007722ea163f43d4115f76a72cfd527111cbd testing/test_nose.py --- a/testing/test_nose.py +++ b/testing/test_nose.py @@ -304,8 +304,9 @@ result = testdir.runpytest() result.stdout.fnmatch_lines("*1 passed*") + at pytest.mark.skipif("sys.version_info < (2,6)") def test_setup_teardown_linking_issue265(testdir): - # we accidnetially didnt integrate nose setupstate with normal setupstate + # we accidentally didnt integrate nose setupstate with normal setupstate # this test ensures that won't happen again testdir.makepyfile(''' import pytest @@ -314,7 +315,8 @@ def test_nothing(self): """Tests the API of the implementation (for generic and specialized).""" - @pytest.mark.skipif("True", reason="Skip tests to check if teardown is skipped as well.") + @pytest.mark.skipif("True", reason= + "Skip tests to check if teardown is skipped as well.") class TestSkipTeardown(TestGeneric): def setup(self): https://bitbucket.org/hpk42/pytest/commits/af95db883582/ Changeset: af95db883582 User: hpk42 Date: 2013-04-16 09:13:58 Summary: merge Affected #: 4 files diff -r 5d9007722ea163f43d4115f76a72cfd527111cbd -r af95db883582c12caf5e6b65b7b2fed022fe6e70 _pytest/capture.py --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -173,8 +173,7 @@ if funcarg_outerr is not None: outerr = (outerr[0] + funcarg_outerr[0], outerr[1] + funcarg_outerr[1]) - if not rep.passed: - addouterr(rep, outerr) + addouterr(rep, outerr) if not rep.passed or rep.when == "teardown": outerr = ('', '') item.outerr = outerr diff -r 5d9007722ea163f43d4115f76a72cfd527111cbd -r af95db883582c12caf5e6b65b7b2fed022fe6e70 _pytest/junitxml.py --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -107,11 +107,20 @@ time=getattr(report, 'duration', 0) )) + def _write_captured_output(self, report): + sec = dict(report.sections) + for name in ('out', 'err'): + content = sec.get("Captured std%s" % name) + if content: + tag = getattr(Junit, 'system-'+name) + self.append(tag(bin_xml_escape(content))) + def append(self, obj): self.tests[-1].append(obj) def append_pass(self, report): self.passed += 1 + self._write_captured_output(report) def append_failure(self, report): #msg = str(report.longrepr.reprtraceback.extraline) @@ -120,16 +129,11 @@ Junit.skipped(message="xfail-marked test passes unexpectedly")) self.skipped += 1 else: - sec = dict(report.sections) fail = Junit.failure(message="test failure") fail.append(str(report.longrepr)) self.append(fail) - for name in ('out', 'err'): - content = sec.get("Captured std%s" % name) - if content: - tag = getattr(Junit, 'system-'+name) - self.append(tag(bin_xml_escape(content))) self.failed += 1 + self._write_captured_output(report) def append_collect_failure(self, report): #msg = str(report.longrepr.reprtraceback.extraline) @@ -162,6 +166,7 @@ message=skipreason )) self.skipped += 1 + self._write_captured_output(report) def pytest_runtest_logreport(self, report): if report.passed: diff -r 5d9007722ea163f43d4115f76a72cfd527111cbd -r af95db883582c12caf5e6b65b7b2fed022fe6e70 _pytest/pdb.py --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -70,16 +70,21 @@ tw.sep(">", "traceback") rep.toterminal(tw) tw.sep(">", "entering PDB") - # A doctest.UnexpectedException is not useful for post_mortem. - # Use the underlying exception instead: - if isinstance(call.excinfo.value, py.std.doctest.UnexpectedException): - tb = call.excinfo.value.exc_info[2] - else: - tb = call.excinfo._excinfo[2] + + tb = self._postmortem_traceback(call.excinfo) post_mortem(tb) rep._pdbshown = True return rep + @staticmethod + def _postmortem_traceback(excinfo): + # A doctest.UnexpectedException is not useful for post_mortem. + # Use the underlying exception instead: + if isinstance(excinfo.value, py.std.doctest.UnexpectedException): + return excinfo.value.exc_info[2] + else: + return excinfo._excinfo[2] + def post_mortem(t): pdb = py.std.pdb class Pdb(pdb.Pdb): diff -r 5d9007722ea163f43d4115f76a72cfd527111cbd -r af95db883582c12caf5e6b65b7b2fed022fe6e70 testing/test_junitxml.py --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -282,13 +282,35 @@ if not sys.platform.startswith("java"): assert "hx" in fnode.toxml() + def test_pass_captures_stdout(self, testdir): + testdir.makepyfile(""" + def test_pass(): + print('hello-stdout') + """) + result, dom = runandparse(testdir) + node = dom.getElementsByTagName("testsuite")[0] + pnode = node.getElementsByTagName("testcase")[0] + systemout = pnode.getElementsByTagName("system-out")[0] + assert "hello-stdout" in systemout.toxml() + + def test_pass_captures_stderr(self, testdir): + testdir.makepyfile(""" + import sys + def test_pass(): + sys.stderr.write('hello-stderr') + """) + result, dom = runandparse(testdir) + node = dom.getElementsByTagName("testsuite")[0] + pnode = node.getElementsByTagName("testcase")[0] + systemout = pnode.getElementsByTagName("system-err")[0] + assert "hello-stderr" in systemout.toxml() + def test_mangle_testnames(): from _pytest.junitxml import mangle_testnames names = ["a/pything.py", "Class", "()", "method"] newnames = mangle_testnames(names) assert newnames == ["a.pything", "Class", "method"] - def test_dont_configure_on_slaves(tmpdir): gotten = [] class FakeConfig: https://bitbucket.org/hpk42/pytest/commits/e648b0ab9f00/ Changeset: e648b0ab9f00 User: hpk42 Date: 2013-04-16 09:14:47 Summary: add to changelog: put captured stdout/stderr into junitxml output even for passing tests (thanks Adam Goucher) Affected #: 1 file diff -r af95db883582c12caf5e6b65b7b2fed022fe6e70 -r e648b0ab9f006799cce2e4ed229eec9d3a26a9c0 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ Changes between 2.3.4 and 2.3.5dev ----------------------------------- +- put captured stdout/stderr into junitxml output even for passing tests + (thanks Adam Goucher) + - Issue 265 - integrate nose setup/teardown with setupstate so it doesnt try to teardown if it did not setup 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. From commits-noreply at bitbucket.org Tue Apr 16 10:51:40 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 16 Apr 2013 08:51:40 -0000 Subject: [Pytest-commit] commit/pytest: 2 new changesets Message-ID: <20130416085140.20609.14706@bitbucket05.managed.contegix.com> 2 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/1597879eb115/ Changeset: 1597879eb115 User: RonnyPfannschmidt Date: 2013-04-16 10:18:08 Summary: turn the postmortem traceback selection to a function Affected #: 1 file diff -r e648b0ab9f006799cce2e4ed229eec9d3a26a9c0 -r 1597879eb1156057925b4656be0ad61b24e73fe7 _pytest/pdb.py --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -71,19 +71,20 @@ rep.toterminal(tw) tw.sep(">", "entering PDB") - tb = self._postmortem_traceback(call.excinfo) + tb = _postmortem_traceback(call.excinfo) post_mortem(tb) rep._pdbshown = True return rep - @staticmethod - def _postmortem_traceback(excinfo): - # A doctest.UnexpectedException is not useful for post_mortem. - # Use the underlying exception instead: - if isinstance(excinfo.value, py.std.doctest.UnexpectedException): - return excinfo.value.exc_info[2] - else: - return excinfo._excinfo[2] + +def _postmortem_traceback(excinfo): + # A doctest.UnexpectedException is not useful for post_mortem. + # Use the underlying exception instead: + if isinstance(excinfo.value, py.std.doctest.UnexpectedException): + return excinfo.value.exc_info[2] + else: + return excinfo._excinfo[2] + def post_mortem(t): pdb = py.std.pdb https://bitbucket.org/hpk42/pytest/commits/ed380ceafe15/ Changeset: ed380ceafe15 User: RonnyPfannschmidt Date: 2013-04-16 10:19:20 Summary: charify pdb visible stack end finding by turning it into a function Affected #: 1 file diff -r 1597879eb1156057925b4656be0ad61b24e73fe7 -r ed380ceafe15f379bc310d1cd43296e0983c6b75 _pytest/pdb.py --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -86,15 +86,20 @@ return excinfo._excinfo[2] +def _find_last_non_hidden_frame(stack): + i = max(0, len(stack) - 1) + while i and stack[i][0].f_locals.get("__tracebackhide__", False): + i -= 1 + return i + + def post_mortem(t): pdb = py.std.pdb class Pdb(pdb.Pdb): def get_stack(self, f, t): stack, i = pdb.Pdb.get_stack(self, f, t) if f is None: - i = max(0, len(stack) - 1) - while i and stack[i][0].f_locals.get("__tracebackhide__", False): - i-=1 + i = _find_last_non_hidden_frame(stack) return stack, i p = Pdb() p.reset() 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. From issues-reply at bitbucket.org Wed Apr 17 16:43:50 2013 From: issues-reply at bitbucket.org (Sorin Sbarnea) Date: Wed, 17 Apr 2013 14:43:50 -0000 Subject: [Pytest-commit] [hpk42/tox] tox page on pypi does not have any links to the project page (issue #94) Message-ID: <20130417144350.5490.56708@bitbucket25.managed.contegix.com> New issue 94: tox page on pypi does not have any links to the project page https://bitbucket.org/hpk42/tox/issue/94/tox-page-on-pypi-does-not-have-any-links Sorin Sbarnea: tox page on pypi https://pypi.python.org/pypi/tox/ does not have any links to the project page, issue tracker, documentation. It contains only the releases. Working example: https://pypi.python.org/pypi/tendo/ - contains information about the project, including documentation, source control, issue tracker, .... From issues-reply at bitbucket.org Wed Apr 17 16:49:08 2013 From: issues-reply at bitbucket.org (Sorin Sbarnea) Date: Wed, 17 Apr 2013 14:49:08 -0000 Subject: [Pytest-commit] [hpk42/tox] provide a standalone mode for tox similar to the one used by py.test (issue #95) Message-ID: <20130417144908.20994.68837@bitbucket01.managed.contegix.com> New issue 95: provide a standalone mode for tox similar to the one used by py.test https://bitbucket.org/hpk42/tox/issue/95/provide-a-standalone-mode-for-tox-similar Sorin Sbarnea: `py.test` can generate a [standalone script](http://pytest.org/latest/goodpractises.html#create-a-py-test-standalone-script) you can run the tests without having to install py.test. This is important for enabling the usage on continuous integration systems where you do not have root access to the running machine (which is usually a clean machine, sometimes even spawned on demand), In order to overcome this, I tried to setup a virtual environment and install tox in it but this doesn't seem to work well, as tox will try to create other virtual environments itself. From commits-noreply at bitbucket.org Thu Apr 18 11:18:38 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Thu, 18 Apr 2013 09:18:38 -0000 Subject: [Pytest-commit] commit/pytest: RonnyPfannschmidt: pdb plugin: move entering pdb into a toplevel function Message-ID: <20130418091838.12602.79507@bitbucket21.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/fdc28ac2029f/ Changeset: fdc28ac2029f User: RonnyPfannschmidt Date: 2013-04-18 11:18:24 Summary: pdb plugin: move entering pdb into a toplevel function this prepares pdb at collect time Affected #: 1 file diff -r ed380ceafe15f379bc310d1cd43296e0983c6b75 -r fdc28ac2029f1c0be1dac4991c2f1b014c39a03f _pytest/pdb.py --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -61,20 +61,26 @@ return rep if hasattr(rep, "wasxfail"): return rep - # we assume that the above execute() suspended capturing - # XXX we re-use the TerminalReporter's terminalwriter - # because this seems to avoid some encoding related troubles - # for not completely clear reasons. - tw = item.config.pluginmanager.getplugin("terminalreporter")._tw - tw.line() - tw.sep(">", "traceback") - rep.toterminal(tw) - tw.sep(">", "entering PDB") + return _enter_pdb(item, call.excinfo, rep) - tb = _postmortem_traceback(call.excinfo) - post_mortem(tb) - rep._pdbshown = True - return rep + + + +def _enter_pdb(item, excinfo, rep): + # we assume that the above execute() suspended capturing + # XXX we re-use the TerminalReporter's terminalwriter + # because this seems to avoid some encoding related troubles + # for not completely clear reasons. + tw = item.config.pluginmanager.getplugin("terminalreporter")._tw + tw.line() + tw.sep(">", "traceback") + rep.toterminal(tw) + tw.sep(">", "entering PDB") + + tb = _postmortem_traceback(excinfo) + post_mortem(tb) + rep._pdbshown = True + return rep def _postmortem_traceback(excinfo): 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. From issues-reply at bitbucket.org Thu Apr 18 22:33:33 2013 From: issues-reply at bitbucket.org (Barry Warsaw) Date: Thu, 18 Apr 2013 20:33:33 -0000 Subject: [Pytest-commit] [hpk42/tox] Can't have a Python 3 setup.py (issue #96) Message-ID: <20130418203333.1531.96532@bitbucket13.managed.contegix.com> New issue 96: Can't have a Python 3 setup.py https://bitbucket.org/hpk42/tox/issue/96/cant-have-a-python-3-setuppy Barry Warsaw: Let's say your setup.py is only Python 3 compatible. tox set up fails when building the sdist: ``` % tox -e py33 GLOB sdist-make: .../setup.py ERROR: invocation failed, logfile: .../.tox/log/tox-0.log ERROR: actionid=tox msg=packaging cmdargs=['/usr/bin/python', local('.../setup.py'), 'sdist', '--formats=zip', '--dist-dir', local('.../.tox/dist')] env=None Traceback (most recent call last): File "setup.py", line 18, in with open('.../version.txt', encoding='utf-8') as fp: TypeError: 'encoding' is an invalid keyword argument for this function ERROR: FAIL could not package project ``` There doesn't seem to be a way to configure this in the tox.ini, though I could be missing it of course. From commits-noreply at bitbucket.org Mon Apr 22 10:36:03 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Mon, 22 Apr 2013 08:36:03 -0000 Subject: [Pytest-commit] commit/pytest: hpk42: allow re-running of a test item (as exercised by the Message-ID: <20130422083603.30082.31681@bitbucket24.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/c4f58165e0d4/ Changeset: c4f58165e0d4 User: hpk42 Date: 2013-04-22 10:35:48 Summary: allow re-running of a test item (as exercised by the pytest-rerunfailures plugins) by re-initializing and removing request/funcargs information in runtestprotocol() - which is a slightly odd place to add funcarg-related functionality but it allows all pytest_runtest_setup/teardown hooks to properly see a valid request/funcarg content on test items. Affected #: 7 files diff -r fdc28ac2029f1c0be1dac4991c2f1b014c39a03f -r c4f58165e0d46166ef7b0b05c3f15ac07387ac10 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ Changes between 2.3.4 and 2.3.5dev ----------------------------------- +- allow re-running of test items / helps to fix pytest-reruntests plugin + and also should help to keep less fixture/resource references alive + - put captured stdout/stderr into junitxml output even for passing tests (thanks Adam Goucher) diff -r fdc28ac2029f1c0be1dac4991c2f1b014c39a03f -r c4f58165e0d46166ef7b0b05c3f15ac07387ac10 _pytest/__init__.py --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.3.5.dev8' +__version__ = '2.3.5.dev16' diff -r fdc28ac2029f1c0be1dac4991c2f1b014c39a03f -r c4f58165e0d46166ef7b0b05c3f15ac07387ac10 _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -917,20 +917,25 @@ self.cls, funcargs=not isyield) self.fixturenames = fi.names_closure - if isyield: - assert not callspec, ( + if callspec is not None: + self.callspec = callspec + self._initrequest() + + def _initrequest(self): + if self._isyieldedfunction(): + assert not hasattr(self, "callspec"), ( "yielded functions (deprecated) cannot have funcargs") self.funcargs = {} else: - if callspec is not None: - self.callspec = callspec - self.funcargs = callspec.funcargs or {} + if hasattr(self, "callspec"): + callspec = self.callspec + self.funcargs = callspec.funcargs.copy() self._genid = callspec.id if hasattr(callspec, "param"): self.param = callspec.param else: self.funcargs = {} - self._request = req = FixtureRequest(self) + self._request = FixtureRequest(self) @property def function(self): diff -r fdc28ac2029f1c0be1dac4991c2f1b014c39a03f -r c4f58165e0d46166ef7b0b05c3f15ac07387ac10 _pytest/runner.py --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -63,12 +63,20 @@ return True def runtestprotocol(item, log=True, nextitem=None): + hasrequest = hasattr(item, "_request") + if hasrequest and not item._request: + item._initrequest() rep = call_and_report(item, "setup", log) reports = [rep] if rep.passed: reports.append(call_and_report(item, "call", log)) reports.append(call_and_report(item, "teardown", log, nextitem=nextitem)) + # after all teardown hooks have been called + # want funcargs and request info to go away + if hasrequest: + item._request = False + item.funcargs = None return reports def pytest_runtest_setup(item): diff -r fdc28ac2029f1c0be1dac4991c2f1b014c39a03f -r c4f58165e0d46166ef7b0b05c3f15ac07387ac10 setup.py --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.3.5.dev8', + version='2.3.5.dev16', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff -r fdc28ac2029f1c0be1dac4991c2f1b014c39a03f -r c4f58165e0d46166ef7b0b05c3f15ac07387ac10 testing/python/integration.py --- a/testing/python/integration.py +++ b/testing/python/integration.py @@ -117,3 +117,35 @@ """) reprec = testdir.inline_run() reprec.assertoutcome(passed=2) + + +class TestReRunTests: + def test_rerun(self, testdir): + testdir.makeconftest(""" + from _pytest.runner import runtestprotocol + def pytest_runtest_protocol(item, nextitem): + runtestprotocol(item, log=False, nextitem=nextitem) + runtestprotocol(item, log=True, nextitem=nextitem) + """) + testdir.makepyfile(""" + import pytest + count = 0 + req = None + @pytest.fixture + def fix(request): + global count, req + assert request != req + req = request + print ("fix count %s" % count) + count += 1 + def test_fix(fix): + pass + """) + result = testdir.runpytest("-s") + result.stdout.fnmatch_lines(""" + *fix count 0* + *fix count 1* + """) + result.stdout.fnmatch_lines(""" + *2 passed* + """) diff -r fdc28ac2029f1c0be1dac4991c2f1b014c39a03f -r c4f58165e0d46166ef7b0b05c3f15ac07387ac10 testing/test_tmpdir.py --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -16,6 +16,7 @@ # pytest_unconfigure has deleted the TempdirHandler already config = item.config config._tmpdirhandler = TempdirHandler(config) + item._initrequest() p = tmpdir(item._request) assert p.check() bn = p.basename.strip("0123456789") 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. From issues-reply at bitbucket.org Thu Apr 25 10:50:07 2013 From: issues-reply at bitbucket.org (Krisztian Fekete) Date: Thu, 25 Apr 2013 08:50:07 -0000 Subject: [Pytest-commit] [hpk42/tox] tox 1.4.3 {[section]name} substitution does not work in general (issue #97) Message-ID: <20130425085007.2532.56079@bitbucket20.managed.contegix.com> New issue 97: tox 1.4.3 {[section]name} substitution does not work in general https://bitbucket.org/hpk42/tox/issue/97/tox-143-section-name-substitution-does-not Krisztian Fekete: I am trying to reuse `tox.ini` with minimal changes between projects/packages - the only variation is in `deps` and the project/package name (see `package` section below). I want `commands` to be the same, so I tried to define an ini variable for package name and reference it from `commands` without success: ``` #!ini [package] name = whatever deps = # package specific dependencies [tox] envlist = py27 [testenv] deps = {[package]deps} # needed by commands nose coverage pep8 pyflakes commands = coverage erase coverage run {envbindir}/nosetests coverage report --show-missing --include={[package]name}/* pyflakes {[package]name} pep8 {[package]name} ``` I get `tox.ConfigError: ConfigError: substitution key '[package]name' not found` with this config. It looks like the ini reading is restricted to known keys only (`{[package]deps}` in `[testenv]deps` works!), so it is currently not possible to introduce & reference new, unknown-to-tox, keys. A potentially related issue is *#38 {[section]name} subsitution does not work for commands* From commits-noreply at bitbucket.org Thu Apr 25 20:23:41 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Thu, 25 Apr 2013 18:23:41 -0000 Subject: [Pytest-commit] commit/tox: 3 new changesets Message-ID: <20130425182341.3727.14765@bitbucket03.managed.contegix.com> 3 new commits in tox: https://bitbucket.org/hpk42/tox/commits/1538fe9d3a7c/ Changeset: 1538fe9d3a7c User: g2p Date: 2012-12-03 18:14:25 Summary: Give further hints on py.test discovery. Affected #: 1 file diff -r e913d5105cc0d286f93bf53f2e30389c292fbbc7 -r 1538fe9d3a7c8334abcc5b342afe2133af889deb doc/example/pytest.txt --- a/doc/example/pytest.txt +++ b/doc/example/pytest.txt @@ -85,14 +85,20 @@ **installed-versus-checkout version**. ``py.test`` collects test modules on the filesystem and then tries to import them under their -`fully qualified name`_. This means that if your test directory contains -an ``__init__.py`` file then your ``py.test`` invocation may end up +`fully qualified name`_. This means that if your test files are +importable from somewhere then your ``py.test`` invocation may end up importing the package from the checkout directory rather than the -installed package. Therefore it is better to try to avoid -``__init__.py`` files in test directories and also try to avoid custom -``PYTHONPATH`` settings. After all, it is the job of your ``setup.py`` -file and the install tools to care for making the package properly -available for importing. +installed package. + +There are a few ways to prevent this. + +With installed tests (the tests are built and installed by setup.py), +one option is to give the explicit path ``{envsitepackagesdir}/mypkg`` +to pytest, and another is to change directories and pass ``--pyargs +mypkg``. With tests that won't be installed, the simplest way is to +avoid ``__init__.py`` files in test directories; pytest will still find +them but they won't be copied to other places and they won't be found by +Python's import system. .. _`fully qualified name`: http://pytest.org/latest/goodpractises.html#package-name https://bitbucket.org/hpk42/tox/commits/8eb9f56e0dd0/ Changeset: 8eb9f56e0dd0 User: g2p Date: 2012-12-03 21:45:13 Summary: Relate to the 2to3 use case. Affected #: 1 file diff -r 1538fe9d3a7c8334abcc5b342afe2133af889deb -r 8eb9f56e0dd068ceaac4328239097230e4a94ba8 doc/example/pytest.txt --- a/doc/example/pytest.txt +++ b/doc/example/pytest.txt @@ -92,15 +92,23 @@ There are a few ways to prevent this. -With installed tests (the tests are built and installed by setup.py), -one option is to give the explicit path ``{envsitepackagesdir}/mypkg`` -to pytest, and another is to change directories and pass ``--pyargs -mypkg``. With tests that won't be installed, the simplest way is to -avoid ``__init__.py`` files in test directories; pytest will still find -them but they won't be copied to other places and they won't be found by -Python's import system. +With installed tests (the tests packages are known to ``setup.py``), a +safe and explicit option is to give the explicit path +``{envsitepackagesdir}/mypkg`` to pytest. +Alternatively, it is possible to use ``changedir`` so that checked-out +files are outside the import path, then pass ``--pyargs mypkg`` to +pytest. + +Installed tests are particularly convenient when combined with +`Distribute's 2to3 support` (``use_2to3``). + +With tests that won't be installed, the simplest way is to avoid +``__init__.py`` files in test directories; pytest will still find them +but they won't be copied to other places or be found by Python's import +system. .. _`fully qualified name`: http://pytest.org/latest/goodpractises.html#package-name +.. _`Distribute's 2to3 support`: http://packages.python.org/distribute/python3.html .. include:: ../links.txt https://bitbucket.org/hpk42/tox/commits/9b7878f71a1e/ Changeset: 9b7878f71a1e User: hpk42 Date: 2013-04-25 20:23:37 Summary: Merged in g2p/tox (pull request #32) Give further hints on py.test discovery. Affected #: 1 file diff -r 1b8bdf9ab87e87203df8543b8e5a85bc30433f52 -r 9b7878f71a1e3846c3a36264fcf322d75682ba19 doc/example/pytest.txt --- a/doc/example/pytest.txt +++ b/doc/example/pytest.txt @@ -85,16 +85,30 @@ **installed-versus-checkout version**. ``py.test`` collects test modules on the filesystem and then tries to import them under their -`fully qualified name`_. This means that if your test directory contains -an ``__init__.py`` file then your ``py.test`` invocation may end up +`fully qualified name`_. This means that if your test files are +importable from somewhere then your ``py.test`` invocation may end up importing the package from the checkout directory rather than the -installed package. Therefore it is better to try to avoid -``__init__.py`` files in test directories and also try to avoid custom -``PYTHONPATH`` settings. After all, it is the job of your ``setup.py`` -file and the install tools to care for making the package properly -available for importing. +installed package. + +There are a few ways to prevent this. + +With installed tests (the tests packages are known to ``setup.py``), a +safe and explicit option is to give the explicit path +``{envsitepackagesdir}/mypkg`` to pytest. +Alternatively, it is possible to use ``changedir`` so that checked-out +files are outside the import path, then pass ``--pyargs mypkg`` to +pytest. + +Installed tests are particularly convenient when combined with +`Distribute's 2to3 support` (``use_2to3``). + +With tests that won't be installed, the simplest way is to avoid +``__init__.py`` files in test directories; pytest will still find them +but they won't be copied to other places or be found by Python's import +system. .. _`fully qualified name`: http://pytest.org/latest/goodpractises.html#package-name +.. _`Distribute's 2to3 support`: http://packages.python.org/distribute/python3.html .. include:: ../links.txt Repository URL: https://bitbucket.org/hpk42/tox/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. From issues-reply at bitbucket.org Thu Apr 25 22:53:43 2013 From: issues-reply at bitbucket.org (vmalloc) Date: Thu, 25 Apr 2013 20:53:43 -0000 Subject: [Pytest-commit] [hpk42/tox] Cannot build python 2.4 configurations (issue #98) Message-ID: <20130425205343.10952.87830@bitbucket21.managed.contegix.com> New issue 98: Cannot build python 2.4 configurations https://bitbucket.org/hpk42/tox/issue/98/cannot-build-python-24-configurations vmalloc: When having a new Python installed, tox attempts to run virtualenv from where it finds it. Recent version of virtualenv require python 2.5 and newer, which causes the virtualenv creation to fail. Is Python 2.4 supported by tox? From commits-noreply at bitbucket.org Sun Apr 28 21:59:36 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Sun, 28 Apr 2013 19:59:36 -0000 Subject: [Pytest-commit] commit/pytest: 3 new changesets Message-ID: <20130428195936.23104.38766@bitbucket02.managed.contegix.com> 3 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/e7240388f09d/ Changeset: e7240388f09d User: flub Date: 2013-04-28 21:56:56 Summary: Minor style cleanup Affected #: 1 file diff -r c4f58165e0d46166ef7b0b05c3f15ac07387ac10 -r e7240388f09d3a2fc3feacb926c601f0c44544b1 _pytest/assertion/util.py --- a/_pytest/assertion/util.py +++ b/_pytest/assertion/util.py @@ -10,6 +10,7 @@ # DebugInterpreter. _reprcompare = None + def format_explanation(explanation): """This formats an explanation @@ -85,7 +86,7 @@ def assertrepr_compare(config, op, left, right): """Return specialised explanations for some operators/operands""" - width = 80 - 15 - len(op) - 2 # 15 chars indentation, 1 space around op + width = 80 - 15 - len(op) - 2 # 15 chars indentation, 1 space around op left_repr = py.io.saferepr(left, maxsize=int(width/2)) right_repr = py.io.saferepr(right, maxsize=width-len(left_repr)) summary = '%s %s %s' % (left_repr, op, right_repr) @@ -114,9 +115,9 @@ raise except: excinfo = py.code.ExceptionInfo() - explanation = ['(pytest_assertion plugin: representation of ' - 'details failed. Probably an object has a faulty __repr__.)', - str(excinfo)] + explanation = [ + '(pytest_assertion plugin: representation of details failed. ' + 'Probably an object has a faulty __repr__.)', str(excinfo)] if not explanation: return None @@ -132,7 +133,7 @@ """ explanation = [] if not verbose: - i = 0 # just in case left or right has zero length + i = 0 # just in case left or right has zero length for i in range(min(len(left), len(right))): if left[i] != right[i]: break @@ -166,13 +167,15 @@ (i, left[i], right[i])] break if len(left) > len(right): - explanation += ['Left contains more items, ' - 'first extra item: %s' % py.io.saferepr(left[len(right)],)] + explanation += [ + 'Left contains more items, first extra item: %s' % + py.io.saferepr(left[len(right)],)] elif len(left) < len(right): - explanation += ['Right contains more items, ' - 'first extra item: %s' % py.io.saferepr(right[len(left)],)] - return explanation # + _diff_text(py.std.pprint.pformat(left), - # py.std.pprint.pformat(right)) + explanation += [ + 'Right contains more items, first extra item: %s' % + py.io.saferepr(right[len(left)],)] + return explanation # + _diff_text(py.std.pprint.pformat(left), + # py.std.pprint.pformat(right)) def _compare_eq_set(left, right, verbose=False): @@ -210,12 +213,12 @@ if extra_left: explanation.append('Left contains more items:') explanation.extend(py.std.pprint.pformat( - dict((k, left[k]) for k in extra_left)).splitlines()) + dict((k, left[k]) for k in extra_left)).splitlines()) extra_right = set(right) - set(left) if extra_right: explanation.append('Right contains more items:') explanation.extend(py.std.pprint.pformat( - dict((k, right[k]) for k in extra_right)).splitlines()) + dict((k, right[k]) for k in extra_right)).splitlines()) return explanation https://bitbucket.org/hpk42/pytest/commits/3c1ac0bc7557/ Changeset: 3c1ac0bc7557 User: flub Date: 2013-04-28 21:57:52 Summary: Ingore rope auto-generated files Affected #: 1 file diff -r e7240388f09d3a2fc3feacb926c601f0c44544b1 -r 3c1ac0bc755735a89375fd747608abfa1e65eaf8 .hgignore --- a/.hgignore +++ b/.hgignore @@ -25,3 +25,4 @@ .tox .cache .coverage +.ropeproject https://bitbucket.org/hpk42/pytest/commits/375daef33f80/ Changeset: 375daef33f80 User: flub Date: 2013-04-28 21:59:10 Summary: Treat frozenset as a set Thanks to Brianna Laugher. Affected #: 2 files diff -r 3c1ac0bc755735a89375fd747608abfa1e65eaf8 -r 375daef33f804b26fdb2e572d1b4fed3e186515b _pytest/assertion/util.py --- a/_pytest/assertion/util.py +++ b/_pytest/assertion/util.py @@ -94,7 +94,7 @@ issequence = lambda x: isinstance(x, (list, tuple)) istext = lambda x: isinstance(x, basestring) isdict = lambda x: isinstance(x, dict) - isset = lambda x: isinstance(x, set) + isset = lambda x: isinstance(x, (set, frozenset)) verbose = config.getoption('verbose') explanation = None diff -r 3c1ac0bc755735a89375fd747608abfa1e65eaf8 -r 375daef33f804b26fdb2e572d1b4fed3e186515b testing/test_assertion.py --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -99,6 +99,11 @@ expl = callequal(set([0, 1]), set([0, 2])) assert len(expl) > 1 + def test_frozenzet(self): + expl = callequal(frozenset([0, 1]), set([0, 2])) + print expl + assert len(expl) > 1 + def test_list_tuples(self): expl = callequal([], [(1,2)]) assert len(expl) > 1 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. From commits-noreply at bitbucket.org Mon Apr 29 10:32:01 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Mon, 29 Apr 2013 08:32:01 -0000 Subject: [Pytest-commit] commit/pytest: hpk42: never consider a fixture function for test function collection Message-ID: <20130429083201.11876.80060@bitbucket05.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/989df06f4c26/ Changeset: 989df06f4c26 User: hpk42 Date: 2013-04-29 10:31:51 Summary: never consider a fixture function for test function collection Affected #: 4 files diff -r 375daef33f804b26fdb2e572d1b4fed3e186515b -r 989df06f4c26be6e15cbe52760be670270a806b2 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,10 @@ Changes between 2.3.4 and 2.3.5dev ----------------------------------- +- never consider a fixture function for test function collection + - allow re-running of test items / helps to fix pytest-reruntests plugin - and also should help to keep less fixture/resource references alive + and also help to keep less fixture/resource references alive - put captured stdout/stderr into junitxml output even for passing tests (thanks Adam Goucher) diff -r 375daef33f804b26fdb2e572d1b4fed3e186515b -r 989df06f4c26be6e15cbe52760be670270a806b2 _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -177,7 +177,8 @@ if collector.classnamefilter(name): Class = collector._getcustomclass("Class") return Class(name, parent=collector) - elif collector.funcnamefilter(name) and hasattr(obj, '__call__'): + elif collector.funcnamefilter(name) and hasattr(obj, '__call__') and \ + getfixturemarker(obj) is None: if is_generator(obj): return Generator(name, parent=collector) else: @@ -1566,15 +1567,7 @@ continue # fixture functions have a pytest_funcarg__ prefix (pre-2.3 style) # or are "@pytest.fixture" marked - try: - marker = obj._pytestfixturefunction - except KeyboardInterrupt: - raise - except Exception: - # some objects raise errors like request (from flask import request) - # we don't expect them to be fixture functions - marker = None - + marker = getfixturemarker(obj) if marker is None: if not name.startswith(self._argprefix): continue @@ -1771,6 +1764,18 @@ def xunitsetup(obj, name): meth = getattr(obj, name, None) - if meth is not None: - if not hasattr(meth, "_pytestfixturefunction"): - return meth + if getfixturemarker(meth) is None: + return meth + +def getfixturemarker(obj): + """ return fixturemarker or None if it doesn't exist or raised + exceptions.""" + try: + return getattr(obj, "_pytestfixturefunction", None) + except KeyboardInterrupt: + raise + except Exception: + # some objects raise errors like request (from flask import request) + # we don't expect them to be fixture functions + return None + diff -r 375daef33f804b26fdb2e572d1b4fed3e186515b -r 989df06f4c26be6e15cbe52760be670270a806b2 testing/python/fixture.py --- a/testing/python/fixture.py +++ b/testing/python/fixture.py @@ -1641,6 +1641,20 @@ reprec = testdir.inline_run("-v") reprec.assertoutcome(passed=6) + def test_fixture_marked_function_not_collected_as_test(self, testdir): + testdir.makepyfile(""" + import pytest + @pytest.fixture + def test_app(): + return 1 + + def test_something(test_app): + assert test_app == 1 + """) + reprec = testdir.inline_run() + reprec.assertoutcome(passed=1) + + class TestRequestScopeAccess: pytestmark = pytest.mark.parametrize(("scope", "ok", "error"),[ ["session", "", "fspath class function module"], diff -r 375daef33f804b26fdb2e572d1b4fed3e186515b -r 989df06f4c26be6e15cbe52760be670270a806b2 testing/test_assertion.py --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -101,7 +101,7 @@ def test_frozenzet(self): expl = callequal(frozenset([0, 1]), set([0, 2])) - print expl + print (expl) assert len(expl) > 1 def test_list_tuples(self): 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. From commits-noreply at bitbucket.org Tue Apr 30 12:06:18 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 30 Apr 2013 10:06:18 -0000 Subject: [Pytest-commit] commit/pytest: hpk42: fix recursion within import hook and source.decode in particular Message-ID: <20130430100618.11678.36743@bitbucket25.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/f4c3910cacf1/ Changeset: f4c3910cacf1 User: hpk42 Date: 2013-04-30 12:05:58 Summary: fix recursion within import hook and source.decode in particular Affected #: 2 files diff -r 989df06f4c26be6e15cbe52760be670270a806b2 -r f4c3910cacf1ba5494814ab465eeba236af956db _pytest/assertion/rewrite.py --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -215,11 +215,17 @@ if (not source.startswith(BOM_UTF8) and (not cookie_re.match(source[0:end1]) or not cookie_re.match(source[end1:end2]))): + if hasattr(state, "_indecode"): + return None # encodings imported us again, we don't rewrite + state._indecode = True try: - source.decode("ascii") - except UnicodeDecodeError: - # Let it fail in real import. - return None + try: + source.decode("ascii") + except UnicodeDecodeError: + # Let it fail in real import. + return None + finally: + del state._indecode # On Python versions which are not 2.7 and less than or equal to 3.1, the # parser expects *nix newlines. if REWRITE_NEWLINES: diff -r 989df06f4c26be6e15cbe52760be670270a806b2 -r f4c3910cacf1ba5494814ab465eeba236af956db testing/test_assertion.py --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -320,3 +320,17 @@ result.stderr.fnmatch_lines([ "*WARNING*assert statements are not executed*", ]) + +def test_recursion_source_decode(testdir): + testdir.makepyfile(""" + def test_something(): + pass + """) + testdir.makeini(""" + [pytest] + python_files = *.py + """) + result = testdir.runpytest("--collectonly") + result.stdout.fnmatch_lines(""" + + """) 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. From commits-noreply at bitbucket.org Tue Apr 30 16:36:19 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 30 Apr 2013 14:36:19 -0000 Subject: [Pytest-commit] commit/pytest: hpk42: release 2.3.5 packaging Message-ID: <20130430143619.14106.83350@bitbucket25.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/commits/fc3a793e87ec/ Changeset: fc3a793e87ec User: hpk42 Date: 2013-04-30 12:26:30 Summary: release 2.3.5 packaging Affected #: 18 files diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a _pytest/__init__.py --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.3.5.dev16' +__version__ = '2.3.5' diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/announce/release-2.3.5.txt --- a/doc/en/announce/release-2.3.5.txt +++ b/doc/en/announce/release-2.3.5.txt @@ -1,23 +1,61 @@ -pytest-2.3.5: bug fixes +pytest-2.3.5: bug fixes and little improvements =========================================================================== -pytest-2.3.5 is a bug fix release for the pytest testing tool. -See the changelog below for details. And +pytest-2.3.5 is a maintenance release with many bug fixes and little +improvements. See the changelog below for details. No backward +compatibility issues are foreseen and all plugins which worked with the +prior version are expected to work unmodified. Speaking of which, a +few interesting new plugins saw the light last month: + +- pytest-instafail: show failure information while tests are running +- pytest-qt: testing of GUI applications written with QT/Pyside +- pytest-xprocess: managing external processes across test runs +- pytest-random: randomize test ordering + +And several others like pytest-django saw maintenance releases. +For a more complete list, check out +https://pypi.python.org/pypi?%3Aaction=search&term=pytest&submit=search. + +For general information see: http://pytest.org/ -for general information. To install or upgrade pytest: +To install or upgrade pytest: pip install -U pytest # or easy_install -U pytest -best, +Particular thanks to Floris, Ronny, Benjamin and the many bug reporters +and fix providers. + +may the fixtures be with you, holger krekel Changes between 2.3.4 and 2.3.5 ----------------------------------- +- never consider a fixture function for test function collection + +- allow re-running of test items / helps to fix pytest-reruntests plugin + and also help to keep less fixture/resource references alive + +- put captured stdout/stderr into junitxml output even for passing tests + (thanks Adam Goucher) + +- Issue 265 - integrate nose setup/teardown with setupstate + so it doesnt try to teardown if it did not setup + +- issue 271 - dont write junitxml on slave nodes + +- Issue 274 - dont try to show full doctest example + when doctest does not know the example location + +- issue 280 - disable assertion rewriting on buggy CPython 2.6.0 + +- inject "getfixture()" helper to retrieve fixtures from doctests, + thanks Andreas Zeidler + - issue 259 - when assertion rewriting, be consistent with the default source encoding of ASCII on Python 2 @@ -26,7 +64,7 @@ - issue250 unicode/str mixes in parametrization names and values now works - issue257, assertion-triggered compilation of source ending in a - comment line doesn't blow up in python2.5 (fixed through py>=1.4.13) + comment line doesn't blow up in python2.5 (fixed through py>=1.4.13.dev6) - fix --genscript option to generate standalone scripts that also work with python3.3 (importer ordering) diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/assert.txt --- a/doc/en/assert.txt +++ b/doc/en/assert.txt @@ -26,7 +26,7 @@ $ py.test test_assert1.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items test_assert1.py F @@ -110,7 +110,7 @@ $ py.test test_assert2.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items test_assert2.py F diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/capture.txt --- a/doc/en/capture.txt +++ b/doc/en/capture.txt @@ -64,7 +64,7 @@ $ py.test =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items test_module.py .F @@ -78,7 +78,7 @@ test_module.py:9: AssertionError ----------------------------- Captured stdout ------------------------------ - setting up + setting up ==================== 1 failed, 1 passed in 0.01 seconds ==================== Accessing captured output from a test function diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/doctest.txt --- a/doc/en/doctest.txt +++ b/doc/en/doctest.txt @@ -44,7 +44,7 @@ $ py.test =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items mymodule.py . diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/example/markers.txt --- a/doc/en/example/markers.txt +++ b/doc/en/example/markers.txt @@ -28,7 +28,7 @@ $ py.test -v -m webtest =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python collecting ... collected 3 items test_server.py:3: test_send_http PASSED @@ -40,7 +40,7 @@ $ py.test -v -m "not webtest" =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python collecting ... collected 3 items test_server.py:6: test_something_quick PASSED @@ -61,7 +61,7 @@ $ py.test -v -k http # running with the above defined example module =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python collecting ... collected 3 items test_server.py:3: test_send_http PASSED @@ -73,7 +73,7 @@ $ py.test -k "not send_http" -v =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python collecting ... collected 3 items test_server.py:6: test_something_quick PASSED @@ -86,7 +86,7 @@ $ py.test -k "http or quick" -v =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python collecting ... collected 3 items test_server.py:3: test_send_http PASSED @@ -232,7 +232,7 @@ $ py.test -E stage2 =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items test_someenv.py s @@ -243,7 +243,7 @@ $ py.test -E stage1 =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items test_someenv.py . @@ -360,12 +360,12 @@ $ py.test -rs # this option reports skip reasons =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 4 items test_plat.py s.s. ========================= short test summary info ========================== - SKIP [2] /tmp/doc-exec-133/conftest.py:12: cannot run on platform linux2 + SKIP [2] /tmp/doc-exec-273/conftest.py:12: cannot run on platform linux2 =================== 2 passed, 2 skipped in 0.01 seconds ==================== @@ -373,7 +373,7 @@ $ py.test -m linux2 =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 4 items test_plat.py . @@ -424,7 +424,7 @@ $ py.test -m interface --tb=short =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 4 items test_module.py FF @@ -445,7 +445,7 @@ $ py.test -m "interface or event" --tb=short =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 4 items test_module.py FFF diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/example/nonpython.txt --- a/doc/en/example/nonpython.txt +++ b/doc/en/example/nonpython.txt @@ -27,7 +27,7 @@ nonpython $ py.test test_simple.yml =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items test_simple.yml .F @@ -37,7 +37,7 @@ usecase execution failed spec failed: 'some': 'other' no further details known at this point. - ==================== 1 failed, 1 passed in 0.09 seconds ==================== + ==================== 1 failed, 1 passed in 0.05 seconds ==================== You get one dot for the passing ``sub1: sub1`` check and one failure. Obviously in the above ``conftest.py`` you'll want to implement a more @@ -56,7 +56,7 @@ nonpython $ py.test -v =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python collecting ... collected 2 items test_simple.yml:1: usecase: ok PASSED @@ -67,17 +67,17 @@ usecase execution failed spec failed: 'some': 'other' no further details known at this point. - ==================== 1 failed, 1 passed in 0.04 seconds ==================== + ==================== 1 failed, 1 passed in 0.05 seconds ==================== While developing your custom test collection and execution it's also interesting to just look at the collection tree:: nonpython $ py.test --collectonly =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items - ============================= in 0.04 seconds ============================= + ============================= in 0.05 seconds ============================= diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/example/parametrize.txt --- a/doc/en/example/parametrize.txt +++ b/doc/en/example/parametrize.txt @@ -104,21 +104,19 @@ $ py.test test_scenarios.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.4.5dev3 - plugins: xdist, oejskit, pep8, cache, couchdbkit, quickcheck + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 4 items test_scenarios.py .... - ========================= 4 passed in 0.04 seconds ========================= + ========================= 4 passed in 0.01 seconds ========================= If you just collect tests you'll also nicely see 'advanced' and 'basic' as variants for the test function:: $ py.test --collectonly test_scenarios.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.4.5dev3 - plugins: xdist, oejskit, pep8, cache, couchdbkit, quickcheck + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 4 items @@ -128,7 +126,7 @@ - ============================= in 0.03 seconds ============================= + ============================= in 0.01 seconds ============================= Note that we told ``metafunc.parametrize()`` that your scenario values should be considered class-scoped. With pytest-2.3 this leads to a @@ -182,14 +180,13 @@ $ py.test test_backends.py --collectonly =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.4.5dev3 - plugins: xdist, oejskit, pep8, cache, couchdbkit, quickcheck + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items - ============================= in 0.03 seconds ============================= + ============================= in 0.00 seconds ============================= And then when we run the test:: @@ -198,7 +195,7 @@ ================================= FAILURES ================================= _________________________ test_db_initialized[d2] __________________________ - db = + db = def test_db_initialized(db): # a dummy test @@ -253,7 +250,7 @@ ================================= FAILURES ================================= ________________________ TestClass.test_equals[1-2] ________________________ - self = , a = 1, b = 2 + self = , a = 1, b = 2 def test_equals(self, a, b): > assert a == b @@ -327,15 +324,14 @@ $ py.test -rs test_module.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.4.5dev3 - plugins: xdist, oejskit, pep8, cache, couchdbkit, quickcheck + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items test_module.py .s ========================= short test summary info ========================== - SKIP [1] /tmp/doc-exec-11/conftest.py:10: could not import 'opt2' + SKIP [1] /tmp/doc-exec-275/conftest.py:10: could not import 'opt2' - =================== 1 passed, 1 skipped in 0.04 seconds ==================== + =================== 1 passed, 1 skipped in 0.01 seconds ==================== You'll see that we don't have a ``opt2`` module and thus the second test run of our ``test_func1`` was skipped. A few notes: diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/example/pythoncollection.txt --- a/doc/en/example/pythoncollection.txt +++ b/doc/en/example/pythoncollection.txt @@ -43,7 +43,7 @@ $ py.test --collectonly =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items @@ -82,7 +82,7 @@ . $ py.test --collectonly pythoncollection.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 3 items @@ -135,7 +135,7 @@ $ py.test --collectonly =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/example/reportingdemo.txt --- a/doc/en/example/reportingdemo.txt +++ b/doc/en/example/reportingdemo.txt @@ -13,7 +13,7 @@ assertion $ py.test failure_demo.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 39 items failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF @@ -30,7 +30,7 @@ failure_demo.py:15: AssertionError _________________________ TestFailing.test_simple __________________________ - self = + self = def test_simple(self): def f(): @@ -40,13 +40,13 @@ > assert f() == g() E assert 42 == 43 - E + where 42 = () - E + and 43 = () + E + where 42 = () + E + and 43 = () failure_demo.py:28: AssertionError ____________________ TestFailing.test_simple_multiline _____________________ - self = + self = def test_simple_multiline(self): otherfunc_multi( @@ -66,19 +66,19 @@ failure_demo.py:11: AssertionError ___________________________ TestFailing.test_not ___________________________ - self = + self = def test_not(self): def f(): return 42 > assert not f() E assert not 42 - E + where 42 = () + E + where 42 = () failure_demo.py:38: AssertionError _________________ TestSpecialisedExplanations.test_eq_text _________________ - self = + self = def test_eq_text(self): > assert 'spam' == 'eggs' @@ -89,7 +89,7 @@ failure_demo.py:42: AssertionError _____________ TestSpecialisedExplanations.test_eq_similar_text _____________ - self = + self = def test_eq_similar_text(self): > assert 'foo 1 bar' == 'foo 2 bar' @@ -102,7 +102,7 @@ failure_demo.py:45: AssertionError ____________ TestSpecialisedExplanations.test_eq_multiline_text ____________ - self = + self = def test_eq_multiline_text(self): > assert 'foo\nspam\nbar' == 'foo\neggs\nbar' @@ -115,15 +115,15 @@ failure_demo.py:48: AssertionError ______________ TestSpecialisedExplanations.test_eq_long_text _______________ - self = + self = def test_eq_long_text(self): a = '1'*100 + 'a' + '2'*100 b = '1'*100 + 'b' + '2'*100 > assert a == b E assert '111111111111...2222222222222' == '1111111111111...2222222222222' - E Skipping 90 identical leading characters in diff - E Skipping 91 identical trailing characters in diff + E Skipping 90 identical leading characters in diff, use -v to show + E Skipping 91 identical trailing characters in diff, use -v to show E - 1111111111a222222222 E ? ^ E + 1111111111b222222222 @@ -132,15 +132,15 @@ failure_demo.py:53: AssertionError _________ TestSpecialisedExplanations.test_eq_long_text_multiline __________ - self = + self = def test_eq_long_text_multiline(self): a = '1\n'*100 + 'a' + '2\n'*100 b = '1\n'*100 + 'b' + '2\n'*100 > assert a == b E assert '1\n1\n1\n1\n...n2\n2\n2\n2\n' == '1\n1\n1\n1\n1...n2\n2\n2\n2\n' - E Skipping 190 identical leading characters in diff - E Skipping 191 identical trailing characters in diff + E Skipping 190 identical leading characters in diff, use -v to show + E Skipping 191 identical trailing characters in diff, use -v to show E 1 E 1 E 1 @@ -156,7 +156,7 @@ failure_demo.py:58: AssertionError _________________ TestSpecialisedExplanations.test_eq_list _________________ - self = + self = def test_eq_list(self): > assert [0, 1, 2] == [0, 1, 3] @@ -166,7 +166,7 @@ failure_demo.py:61: AssertionError ______________ TestSpecialisedExplanations.test_eq_list_long _______________ - self = + self = def test_eq_list_long(self): a = [0]*100 + [1] + [3]*100 @@ -178,20 +178,23 @@ failure_demo.py:66: AssertionError _________________ TestSpecialisedExplanations.test_eq_dict _________________ - self = + self = def test_eq_dict(self): - > assert {'a': 0, 'b': 1} == {'a': 0, 'b': 2} - E assert {'a': 0, 'b': 1} == {'a': 0, 'b': 2} - E - {'a': 0, 'b': 1} - E ? ^ - E + {'a': 0, 'b': 2} - E ? ^ + > assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0} + E assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0} + E Hiding 1 identical items, use -v to show + E Differing items: + E {'b': 1} != {'b': 2} + E Left contains more items: + E {'c': 0} + E Right contains more items: + E {'d': 0} failure_demo.py:69: AssertionError _________________ TestSpecialisedExplanations.test_eq_set __________________ - self = + self = def test_eq_set(self): > assert set([0, 10, 11, 12]) == set([0, 20, 21]) @@ -207,7 +210,7 @@ failure_demo.py:72: AssertionError _____________ TestSpecialisedExplanations.test_eq_longer_list ______________ - self = + self = def test_eq_longer_list(self): > assert [1,2] == [1,2,3] @@ -217,7 +220,7 @@ failure_demo.py:75: AssertionError _________________ TestSpecialisedExplanations.test_in_list _________________ - self = + self = def test_in_list(self): > assert 1 in [0, 2, 3, 4, 5] @@ -226,7 +229,7 @@ failure_demo.py:78: AssertionError __________ TestSpecialisedExplanations.test_not_in_text_multiline __________ - self = + self = def test_not_in_text_multiline(self): text = 'some multiline\ntext\nwhich\nincludes foo\nand a\ntail' @@ -244,7 +247,7 @@ failure_demo.py:82: AssertionError ___________ TestSpecialisedExplanations.test_not_in_text_single ____________ - self = + self = def test_not_in_text_single(self): text = 'single foo line' @@ -257,7 +260,7 @@ failure_demo.py:86: AssertionError _________ TestSpecialisedExplanations.test_not_in_text_single_long _________ - self = + self = def test_not_in_text_single_long(self): text = 'head ' * 50 + 'foo ' + 'tail ' * 20 @@ -270,7 +273,7 @@ failure_demo.py:90: AssertionError ______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______ - self = + self = def test_not_in_text_single_long_term(self): text = 'head ' * 50 + 'f'*70 + 'tail ' * 20 @@ -289,7 +292,7 @@ i = Foo() > assert i.b == 2 E assert 1 == 2 - E + where 1 = .b + E + where 1 = .b failure_demo.py:101: AssertionError _________________________ test_attribute_instance __________________________ @@ -299,8 +302,8 @@ b = 1 > assert Foo().b == 2 E assert 1 == 2 - E + where 1 = .b - E + where = () + E + where 1 = .b + E + where = () failure_demo.py:107: AssertionError __________________________ test_attribute_failure __________________________ @@ -316,7 +319,7 @@ failure_demo.py:116: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - self = + self = def _get_b(self): > raise Exception('Failed to get attrib') @@ -332,15 +335,15 @@ b = 2 > assert Foo().b == Bar().b E assert 1 == 2 - E + where 1 = .b - E + where = () - E + and 2 = .b - E + where = () + E + where 1 = .b + E + where = () + E + and 2 = .b + E + where = () failure_demo.py:124: AssertionError __________________________ TestRaises.test_raises __________________________ - self = + self = def test_raises(self): s = 'qwe' @@ -352,10 +355,10 @@ > int(s) E ValueError: invalid literal for int() with base 10: 'qwe' - <0-codegen /home/hpk/p/pytest/.tox/regen/lib/python2.7/site-packages/_pytest/python.py:851>:1: ValueError + <0-codegen /home/hpk/p/pytest/.tox/regen/local/lib/python2.7/site-packages/_pytest/python.py:858>:1: ValueError ______________________ TestRaises.test_raises_doesnt _______________________ - self = + self = def test_raises_doesnt(self): > raises(IOError, "int('3')") @@ -364,7 +367,7 @@ failure_demo.py:136: Failed __________________________ TestRaises.test_raise ___________________________ - self = + self = def test_raise(self): > raise ValueError("demo error") @@ -373,7 +376,7 @@ failure_demo.py:139: ValueError ________________________ TestRaises.test_tupleerror ________________________ - self = + self = def test_tupleerror(self): > a,b = [1] @@ -382,7 +385,7 @@ failure_demo.py:142: ValueError ______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______ - self = + self = def test_reinterpret_fails_with_print_for_the_fun_of_it(self): l = [1,2,3] @@ -395,7 +398,7 @@ l is [1, 2, 3] ________________________ TestRaises.test_some_error ________________________ - self = + self = def test_some_error(self): > if namenotexi: @@ -423,7 +426,7 @@ <2-codegen 'abc-123' /home/hpk/p/pytest/doc/en/example/assertion/failure_demo.py:162>:2: AssertionError ____________________ TestMoreErrors.test_complex_error _____________________ - self = + self = def test_complex_error(self): def f(): @@ -452,7 +455,7 @@ failure_demo.py:5: AssertionError ___________________ TestMoreErrors.test_z1_unpack_error ____________________ - self = + self = def test_z1_unpack_error(self): l = [] @@ -462,7 +465,7 @@ failure_demo.py:179: ValueError ____________________ TestMoreErrors.test_z2_type_error _____________________ - self = + self = def test_z2_type_error(self): l = 3 @@ -472,19 +475,19 @@ failure_demo.py:183: TypeError ______________________ TestMoreErrors.test_startswith ______________________ - self = + self = def test_startswith(self): s = "123" g = "456" > assert s.startswith(g) - E assert ('456') - E + where = '123'.startswith + E assert ('456') + E + where = '123'.startswith failure_demo.py:188: AssertionError __________________ TestMoreErrors.test_startswith_nested ___________________ - self = + self = def test_startswith_nested(self): def f(): @@ -492,15 +495,15 @@ def g(): return "456" > assert f().startswith(g()) - E assert ('456') - E + where = '123'.startswith - E + where '123' = () - E + and '456' = () + E assert ('456') + E + where = '123'.startswith + E + where '123' = () + E + and '456' = () failure_demo.py:195: AssertionError _____________________ TestMoreErrors.test_global_func ______________________ - self = + self = def test_global_func(self): > assert isinstance(globf(42), float) @@ -510,18 +513,18 @@ failure_demo.py:198: AssertionError _______________________ TestMoreErrors.test_instance _______________________ - self = + self = def test_instance(self): self.x = 6*7 > assert self.x != 42 E assert 42 != 42 - E + where 42 = .x + E + where 42 = .x failure_demo.py:202: AssertionError _______________________ TestMoreErrors.test_compare ________________________ - self = + self = def test_compare(self): > assert globf(10) < 5 @@ -531,7 +534,7 @@ failure_demo.py:205: AssertionError _____________________ TestMoreErrors.test_try_finally ______________________ - self = + self = def test_try_finally(self): x = 1 @@ -540,4 +543,4 @@ E assert 1 == 0 failure_demo.py:210: AssertionError - ======================== 39 failed in 0.25 seconds ========================= + ======================== 39 failed in 0.21 seconds ========================= diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/example/simple.txt --- a/doc/en/example/simple.txt +++ b/doc/en/example/simple.txt @@ -106,7 +106,7 @@ $ py.test =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 0 items ============================= in 0.00 seconds ============================= @@ -150,12 +150,12 @@ $ py.test -rs # "-rs" means report details on the little 's' =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items test_module.py .s ========================= short test summary info ========================== - SKIP [1] /tmp/doc-exec-138/conftest.py:9: need --runslow option to run + SKIP [1] /tmp/doc-exec-278/conftest.py:9: need --runslow option to run =================== 1 passed, 1 skipped in 0.01 seconds ==================== @@ -163,7 +163,7 @@ $ py.test --runslow =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items test_module.py .. @@ -253,7 +253,7 @@ $ py.test =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 project deps: mylib-1.1 collected 0 items @@ -276,7 +276,7 @@ $ py.test -v =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python info1: did you know that ... did you? collecting ... collected 0 items @@ -287,7 +287,7 @@ $ py.test =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 0 items ============================= in 0.00 seconds ============================= @@ -319,7 +319,7 @@ $ py.test --durations=3 =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 3 items test_some_are_slow.py ... @@ -327,7 +327,7 @@ ========================= slowest 3 test durations ========================= 0.20s call test_some_are_slow.py::test_funcslow2 0.10s call test_some_are_slow.py::test_funcslow1 - 0.00s call test_some_are_slow.py::test_funcfast + 0.00s setup test_some_are_slow.py::test_funcfast ========================= 3 passed in 0.31 seconds ========================= incremental testing - test steps @@ -380,7 +380,7 @@ $ py.test -rx =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 4 items test_step.py .Fx. @@ -388,7 +388,7 @@ ================================= FAILURES ================================= ____________________ TestUserHandling.test_modification ____________________ - self = + self = def test_modification(self): > assert 0 @@ -398,7 +398,7 @@ ========================= short test summary info ========================== XFAIL test_step.py::TestUserHandling::()::test_deletion reason: previous test failed (test_modification) - ============== 1 failed, 2 passed, 1 xfailed in 0.02 seconds =============== + ============== 1 failed, 2 passed, 1 xfailed in 0.01 seconds =============== We'll see that ``test_deletion`` was not executed because ``test_modification`` failed. It is reported as an "expected failure". @@ -450,7 +450,7 @@ $ py.test =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 7 items test_step.py .Fx. @@ -460,17 +460,17 @@ ================================== ERRORS ================================== _______________________ ERROR at setup of test_root ________________________ - file /tmp/doc-exec-138/b/test_error.py, line 1 + file /tmp/doc-exec-278/b/test_error.py, line 1 def test_root(db): # no db here, will error out fixture 'db' not found available fixtures: pytestconfig, recwarn, monkeypatch, capfd, capsys, tmpdir use 'py.test --fixtures [testpath]' for help on them. - /tmp/doc-exec-138/b/test_error.py:1 + /tmp/doc-exec-278/b/test_error.py:1 ================================= FAILURES ================================= ____________________ TestUserHandling.test_modification ____________________ - self = + self = def test_modification(self): > assert 0 @@ -479,23 +479,23 @@ test_step.py:9: AssertionError _________________________________ test_a1 __________________________________ - db = + db = def test_a1(db): > assert 0, db # to show value - E AssertionError: + E AssertionError: a/test_db.py:2: AssertionError _________________________________ test_a2 __________________________________ - db = + db = def test_a2(db): > assert 0, db # to show value - E AssertionError: + E AssertionError: a/test_db2.py:2: AssertionError - ========== 3 failed, 2 passed, 1 xfailed, 1 error in 0.04 seconds ========== + ========== 3 failed, 2 passed, 1 xfailed, 1 error in 0.03 seconds ========== The two test modules in the ``a`` directory see the same ``db`` fixture instance while the one test in the sister-directory ``b`` doesn't see it. We could of course @@ -550,7 +550,7 @@ $ py.test test_module.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items test_module.py FF @@ -558,7 +558,7 @@ ================================= FAILURES ================================= ________________________________ test_fail1 ________________________________ - tmpdir = local('/tmp/pytest-543/test_fail10') + tmpdir = local('/tmp/pytest-326/test_fail10') def test_fail1(tmpdir): > assert 0 @@ -577,7 +577,7 @@ you will have a "failures" file which contains the failing test ids:: $ cat failures - test_module.py::test_fail1 (/tmp/pytest-543/test_fail10) + test_module.py::test_fail1 (/tmp/pytest-326/test_fail10) test_module.py::test_fail2 Making test result information available in fixtures @@ -640,7 +640,7 @@ $ py.test -s test_module.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 3 items test_module.py EFF diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/fixture.txt --- a/doc/en/fixture.txt +++ b/doc/en/fixture.txt @@ -71,7 +71,7 @@ $ py.test test_smtpsimple.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items test_smtpsimple.py F @@ -79,7 +79,7 @@ ================================= FAILURES ================================= ________________________________ test_ehlo _________________________________ - smtp = + smtp = def test_ehlo(smtp): response, msg = smtp.ehlo() @@ -89,7 +89,7 @@ E assert 0 test_smtpsimple.py:12: AssertionError - ========================= 1 failed in 0.17 seconds ========================= + ========================= 1 failed in 0.20 seconds ========================= In the failure traceback we see that the test function was called with a ``smtp`` argument, the ``smtplib.SMTP()`` instance created by the fixture @@ -189,7 +189,7 @@ $ py.test test_module.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items test_module.py FF @@ -197,7 +197,7 @@ ================================= FAILURES ================================= ________________________________ test_ehlo _________________________________ - smtp = + smtp = def test_ehlo(smtp): response = smtp.ehlo() @@ -209,7 +209,7 @@ test_module.py:6: AssertionError ________________________________ test_noop _________________________________ - smtp = + smtp = def test_noop(smtp): response = smtp.noop() @@ -218,7 +218,7 @@ E assert 0 test_module.py:11: AssertionError - ========================= 2 failed in 0.23 seconds ========================= + ========================= 2 failed in 0.26 seconds ========================= You see the two ``assert 0`` failing and more importantly you can also see that the same (module-scoped) ``smtp`` object was passed into the two @@ -271,7 +271,7 @@ $ py.test -s -q --tb=no FF - finalizing + finalizing We see that the ``smtp`` instance is finalized after the two tests using it tests executed. If we had specified ``scope='function'`` @@ -298,7 +298,6 @@ > assert 0, smtp.helo() E AssertionError: (250, 'mail.python.org') - .. _`fixture-parametrize`: Parametrizing a fixture @@ -341,7 +340,7 @@ ================================= FAILURES ================================= __________________________ test_ehlo[merlinux.eu] __________________________ - smtp = + smtp = def test_ehlo(smtp): response = smtp.ehlo() @@ -353,7 +352,7 @@ test_module.py:6: AssertionError __________________________ test_noop[merlinux.eu] __________________________ - smtp = + smtp = def test_noop(smtp): response = smtp.noop() @@ -364,18 +363,18 @@ test_module.py:11: AssertionError ________________________ test_ehlo[mail.python.org] ________________________ - smtp = + smtp = def test_ehlo(smtp): response = smtp.ehlo() assert response[0] == 250 > assert "merlinux" in response[1] - E assert 'merlinux' in 'mail.python.org\nSIZE 10240000\nETRN\nSTARTTLS\nENHANCEDSTATUSCODES\n8BITMIME\nDSN' + E assert 'merlinux' in 'mail.python.org\nSIZE 25600000\nETRN\nSTARTTLS\nENHANCEDSTATUSCODES\n8BITMIME\nDSN' test_module.py:5: AssertionError ________________________ test_noop[mail.python.org] ________________________ - smtp = + smtp = def test_noop(smtp): response = smtp.noop() @@ -423,13 +422,13 @@ $ py.test -v test_appsetup.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python collecting ... collected 2 items test_appsetup.py:12: test_smtp_exists[merlinux.eu] PASSED test_appsetup.py:12: test_smtp_exists[mail.python.org] PASSED - ========================= 2 passed in 5.95 seconds ========================= + ========================= 2 passed in 5.38 seconds ========================= Due to the parametrization of ``smtp`` the test will run twice with two different ``App`` instances and respective smtp servers. There is no @@ -488,7 +487,7 @@ $ py.test -v -s test_module.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 -- /home/hpk/p/pytest/.tox/regen/bin/python + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 -- /home/hpk/p/pytest/.tox/regen/bin/python collecting ... collected 8 items test_module.py:16: test_0[1] PASSED diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/getting-started.txt --- a/doc/en/getting-started.txt +++ b/doc/en/getting-started.txt @@ -23,7 +23,7 @@ To check your installation has installed the correct version:: $ py.test --version - This is py.test version 2.3.4, imported from /home/hpk/p/pytest/.tox/regen/lib/python2.7/site-packages/pytest.pyc + This is py.test version 2.3.5, imported from /home/hpk/p/pytest/.tox/regen/local/lib/python2.7/site-packages/pytest.py If you get an error checkout :ref:`installation issues`. @@ -45,7 +45,7 @@ $ py.test =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items test_sample.py F @@ -122,7 +122,7 @@ ================================= FAILURES ================================= ____________________________ TestClass.test_two ____________________________ - self = + self = def test_two(self): x = "hello" @@ -157,7 +157,7 @@ ================================= FAILURES ================================= _____________________________ test_needsfiles ______________________________ - tmpdir = local('/tmp/pytest-539/test_needsfiles0') + tmpdir = local('/tmp/pytest-322/test_needsfiles0') def test_needsfiles(tmpdir): print tmpdir @@ -166,7 +166,7 @@ test_tmpdir.py:3: AssertionError ----------------------------- Captured stdout ------------------------------ - /tmp/pytest-539/test_needsfiles0 + /tmp/pytest-322/test_needsfiles0 Before the test runs, a unique-per-test-invocation temporary directory was created. More info at :ref:`tmpdir handling`. diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/parametrize.txt --- a/doc/en/parametrize.txt +++ b/doc/en/parametrize.txt @@ -53,7 +53,7 @@ $ py.test =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 3 items test_expectation.py ..F @@ -135,8 +135,8 @@ def test_valid_string(stringinput): > assert stringinput.isalpha() - E assert () - E + where = '!'.isalpha + E assert () + E + where = '!'.isalpha test_strings.py:3: AssertionError @@ -149,7 +149,7 @@ $ py.test -q -rs test_strings.py s ========================= short test summary info ========================== - SKIP [1] /home/hpk/p/pytest/.tox/regen/lib/python2.7/site-packages/_pytest/python.py:962: got empty parameter set, function test_valid_string at /tmp/doc-exec-101/test_strings.py:1 + SKIP [1] /home/hpk/p/pytest/.tox/regen/local/lib/python2.7/site-packages/_pytest/python.py:974: got empty parameter set, function test_valid_string at /tmp/doc-exec-240/test_strings.py:1 For further examples, you might want to look at :ref:`more parametrization examples `. diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/skipping.txt --- a/doc/en/skipping.txt +++ b/doc/en/skipping.txt @@ -132,7 +132,7 @@ example $ py.test -rx xfail_demo.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 6 items xfail_demo.py xxxxxx diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/tmpdir.txt --- a/doc/en/tmpdir.txt +++ b/doc/en/tmpdir.txt @@ -29,7 +29,7 @@ $ py.test test_tmpdir.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 1 items test_tmpdir.py F @@ -37,7 +37,7 @@ ================================= FAILURES ================================= _____________________________ test_create_file _____________________________ - tmpdir = local('/tmp/pytest-540/test_create_file0') + tmpdir = local('/tmp/pytest-323/test_create_file0') def test_create_file(tmpdir): p = tmpdir.mkdir("sub").join("hello.txt") diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a doc/en/unittest.txt --- a/doc/en/unittest.txt +++ b/doc/en/unittest.txt @@ -88,7 +88,7 @@ $ py.test test_unittest_db.py =========================== test session starts ============================ - platform linux2 -- Python 2.7.3 -- pytest-2.3.4 + platform linux2 -- Python 2.7.3 -- pytest-2.3.5 collected 2 items test_unittest_db.py FF @@ -101,7 +101,7 @@ def test_method1(self): assert hasattr(self, "db") > assert 0, self.db # fail for demo purposes - E AssertionError: + E AssertionError: test_unittest_db.py:9: AssertionError ___________________________ MyTest.test_method2 ____________________________ @@ -110,7 +110,7 @@ def test_method2(self): > assert 0, self.db # fail for demo purposes - E AssertionError: + E AssertionError: test_unittest_db.py:12: AssertionError ========================= 2 failed in 0.02 seconds ========================= diff -r f4c3910cacf1ba5494814ab465eeba236af956db -r fc3a793e87ec907000a47ea0d3a372a2fe218c0a setup.py --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.3.5.dev16', + version='2.3.5', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], 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. From commits-noreply at bitbucket.org Tue Apr 30 16:55:32 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 30 Apr 2013 14:55:32 -0000 Subject: [Pytest-commit] commit/tox: 2 new changesets Message-ID: <20130430145532.20134.12582@bitbucket22.managed.contegix.com> 2 new commits in tox: https://bitbucket.org/hpk42/tox/commits/c57c9607135a/ Changeset: c57c9607135a User: kfekete Date: 2013-04-27 01:03:59 Summary: Tests for issue #97 {[section]name} substitution does not work in general Affected #: 1 file diff -r 9b7878f71a1e3846c3a36264fcf322d75682ba19 -r c57c9607135ab15517954e92d897f42999dd4c5e tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -176,6 +176,29 @@ py.test.raises(tox.exception.ConfigError, 'reader.getdefault("section", "key2")') + def test_getdefault_other_section_substitution(self, newconfig): + config = newconfig(""" + [section] + key = rue + [testenv] + key = t{[section]key} + """) + reader = IniReader(config._cfg) + x = reader.getdefault("testenv", "key") + assert x == "true" + + def test_command_substitution_from_other_section(self, newconfig): + config = newconfig(""" + [section] + key = whatever + [testenv] + commands = + echo {[section]key} + """) + reader = IniReader(config._cfg) + x = reader.getargvlist("testenv", "commands") + assert x == [["echo", "whatever"]] + def test_argvlist(self, tmpdir, newconfig): config = newconfig(""" [section] https://bitbucket.org/hpk42/tox/commits/5603e77786d8/ Changeset: 5603e77786d8 User: kfekete Date: 2013-04-27 01:04:07 Summary: Fix issue #97 {[section]name} substitution does not work in general Affected #: 1 file diff -r c57c9607135ab15517954e92d897f42999dd4c5e -r 5603e77786d87525364e0006c0cd16fc1654b772 tox/_config.py --- a/tox/_config.py +++ b/tox/_config.py @@ -345,6 +345,9 @@ self.name = name self.url = url +RE_ITEM_REF = re.compile(r'\{(?:(?P[^[:]+):)?(?P.*)\}') +# temporary workaround for sublime text syntax highlight bug: ]))' + class IniReader: def __init__(self, cfgparser, fallbacksections=None): self._cfg = cfgparser @@ -411,7 +414,6 @@ def _processcommand(self, command): posargs = self._subs.get('_posargs', None) - pat = r'\{(?:(?P[^:]+):)?(?P.*)\}' words = list(CommandParser(command).words()) new_command = '' for word in words: @@ -420,9 +422,9 @@ new_command += ' '.join(posargs) continue - new_word = re.sub(pat, self._replace_match, word) + new_word = self._replace(word, quote=True) # two passes; we might have substitutions in the result - new_word = re.sub(pat, self._replace_match, new_word) + new_word = self._replace(new_word, quote=True) new_command += new_word return shlex.split(new_command.strip()) @@ -464,38 +466,7 @@ #print "getdefault", section, name, "returned", repr(x) return x - def _sub(self, match): - key = match.group(0)[1:-1] - if key.startswith("env:"): - envkey = key[4:] - if envkey not in os.environ: - raise tox.exception.ConfigError( - "substitution %r: %r not found in environment" % - (key, envkey)) - return os.environ[envkey] - val = self._subs.get(key, None) - if val is None: - if key.startswith("[") and "]" in key: - i = key.find("]") - section, item = key[1:i], key[i+1:] - if section in self._cfg and item in self._cfg[section]: - if (section, item) in self._subststack: - raise ValueError('%s already in %s' %( - (section, item), self._subststack)) - x = str(self._cfg[section][item]) - self._subststack.append((section, item)) - try: - return self._replace(x) - finally: - self._subststack.pop() - - raise tox.exception.ConfigError( - "substitution key %r not found" % key) - elif py.builtin.callable(val): - val = val() - return str(val) - - def _replace_posargs(self, match): + def _replace_posargs(self, match, quote): return self._do_replace_posargs(lambda: match.group('substitution_value')) def _do_replace_posargs(self, value_func): @@ -510,7 +481,7 @@ return '' - def _replace_env(self, match): + def _replace_env(self, match, quote): envkey = match.group('substitution_value') if not envkey: raise tox.exception.ConfigError( @@ -523,21 +494,41 @@ return os.environ[envkey] - def _replace_substitution(self, match): + def _substitute_from_other_section(self, key, quote): + if key.startswith("[") and "]" in key: + i = key.find("]") + section, item = key[1:i], key[i+1:] + if section in self._cfg and item in self._cfg[section]: + if (section, item) in self._subststack: + raise ValueError('%s already in %s' %( + (section, item), self._subststack)) + x = str(self._cfg[section][item]) + self._subststack.append((section, item)) + try: + return self._replace(x, quote=quote) + finally: + self._subststack.pop() + + raise tox.exception.ConfigError( + "substitution key %r not found" % key) + + def _replace_substitution(self, match, quote): sub_key = match.group('substitution_value') - if sub_key not in self._subs: - raise tox.exception.ConfigError( - "substitution key %r not found" % sub_key) - val = self._subs[sub_key] + val = self._subs.get(sub_key, None) + if val is None: + val = self._substitute_from_other_section(sub_key, quote) if py.builtin.callable(val): val = val() - return '"%s"' % str(val).replace('"', r'\"') + if quote: + return '"%s"' % str(val).replace('"', r'\"') + else: + return str(val) def _is_bare_posargs(self, groupdict): return groupdict.get('substitution_value', None) == 'posargs' \ and not groupdict.get('sub_type') - def _replace_match(self, match): + def _replace_match(self, match, quote): g = match.groupdict() # special case: posargs. If there is a 'posargs' substitution value @@ -560,11 +551,23 @@ except KeyError: raise tox.exception.ConfigError("No support for the %s substitution type" % sub_type) - return handler(match) + # quoting is done in handlers, as at least posargs handling is special: + # all of its arguments are inserted as separate parameters + return handler(match, quote) - def _replace(self, x, rexpattern = re.compile("\{.+?\}")): + def _replace_match_quote(self, match): + return self._replace_match(match, quote=True) + def _replace_match_no_quote(self, match): + return self._replace_match(match, quote=False) + + def _replace(self, x, rexpattern=RE_ITEM_REF, quote=False): + # XXX is rexpattern used by callers? can it be removed? if '{' in x: - return rexpattern.sub(self._sub, x) + if quote: + replace_func = self._replace_match_quote + else: + replace_func = self._replace_match_no_quote + return rexpattern.sub(replace_func, x) return x def _parse_command(self, command): Repository URL: https://bitbucket.org/hpk42/tox/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. From commits-noreply at bitbucket.org Tue Apr 30 16:57:42 2013 From: commits-noreply at bitbucket.org (commits-noreply at bitbucket.org) Date: Tue, 30 Apr 2013 14:57:42 -0000 Subject: [Pytest-commit] commit/tox: hpk42: add changelog entry for fix of issue97 - allow substitutions to Message-ID: <20130430145742.20134.10383@bitbucket22.managed.contegix.com> 1 new commit in tox: https://bitbucket.org/hpk42/tox/commits/1aadfbd68cff/ Changeset: 1aadfbd68cff User: hpk42 Date: 2013-04-30 16:57:31 Summary: add changelog entry for fix of issue97 - allow substitutions to reference from other sections (thanks Krisztian Fekete) Affected #: 5 files diff -r 5603e77786d87525364e0006c0cd16fc1654b772 -r 1aadfbd68cfff77e57ef36ffb8ec5a54b40217d8 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ 1.5.0.dev ----------------- +- fix issue97 - allow substitutions to reference from other sections + (thanks Krisztian Fekete) + - fix issue92 - fix {envsitepackagesdir} to actually work again - re-license tox to MIT license diff -r 5603e77786d87525364e0006c0cd16fc1654b772 -r 1aadfbd68cfff77e57ef36ffb8ec5a54b40217d8 CONTRIBUTORS --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,6 +1,7 @@ contributions: +Krisztian Fekete Marc Abramowitz Sridhar Ratnakumar Chris Rose diff -r 5603e77786d87525364e0006c0cd16fc1654b772 -r 1aadfbd68cfff77e57ef36ffb8ec5a54b40217d8 setup.py --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ description='virtualenv-based automation of test activities', long_description=long_description, url='http://tox.testrun.org/', - version='1.5.dev6', + version='1.5.dev7', license='http://opensource.org/licenses/MIT', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], author='holger krekel', diff -r 5603e77786d87525364e0006c0cd16fc1654b772 -r 1aadfbd68cfff77e57ef36ffb8ec5a54b40217d8 tox/__init__.py --- a/tox/__init__.py +++ b/tox/__init__.py @@ -1,5 +1,5 @@ # -__version__ = '1.5.dev6' +__version__ = '1.5.dev7' class exception: class Error(Exception): diff -r 5603e77786d87525364e0006c0cd16fc1654b772 -r 1aadfbd68cfff77e57ef36ffb8ec5a54b40217d8 toxbootstrap.py --- a/toxbootstrap.py +++ b/toxbootstrap.py @@ -58,7 +58,7 @@ """ -__version__ = '1.5.0.dev2' +__version__ = '1.5.dev7' import sys import os Repository URL: https://bitbucket.org/hpk42/tox/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.