diff --git a/CHANGELOG b/CHANGELOG index d2dc1fad4..68f9ba4f6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,7 +6,8 @@ Changes between 1.0.0b7 and 1.0.0b8 talk/tutorial doc page * fixed teardown problem related to partially failing funcarg setups - (thanks MrTopf for reporting) + (thanks MrTopf for reporting), "pytest_runtest_teardown" is now + always invoked even if the "pytest_runtest_setup" failed. * tweaked doctest output for docstrings in py modules, thanks Radomir. diff --git a/MANIFEST b/MANIFEST index 1df6326bc..a0df0384f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,8 +1,6 @@ -MANIFEST -py/__init__.py -setup.py CHANGELOG LICENSE +MANIFEST README.txt _findpy.py doc/announce/release-0.9.0.txt @@ -31,6 +29,7 @@ doc/test/extend.txt doc/test/features.txt doc/test/funcargs.txt doc/test/quickstart.txt +doc/test/talks.txt doc/test/test.txt doc/test/xunit_setup.txt doc/xml.txt @@ -58,6 +57,7 @@ example/pytest/failure_demo.py example/pytest/test_failures.py example/pytest/test_setup_flow_example.py py/LICENSE +py/__init__.py py/_com.py py/bin/_findpy.py py/bin/_genscripts.py @@ -333,6 +333,7 @@ py/test/plugin/pytest_tmpdir.py py/test/plugin/pytest_unittest.py py/test/plugin/pytest_xfail.py py/test/plugin/test_pytest_runner.py +py/test/plugin/test_pytest_runner_xunit.py py/test/pluginmanager.py py/test/pycollect.py py/test/session.py @@ -358,7 +359,6 @@ py/test/testing/test_pluginmanager.py py/test/testing/test_pycollect.py py/test/testing/test_recording.py py/test/testing/test_session.py -py/test/testing/test_setup_functional.py py/test/testing/test_traceback.py py/test/web/__init__.py py/test/web/exception.py @@ -382,3 +382,4 @@ py/xmlobj/testing/test_html.py py/xmlobj/testing/test_xml.py py/xmlobj/visit.py py/xmlobj/xml.py +setup.py \ No newline at end of file diff --git a/py/__init__.py b/py/__init__.py index d042266d4..f63c95ad4 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -19,7 +19,7 @@ For questions please check out http://pylib.org/contact.html """ from initpkg import initpkg -version = "1.0.0b7" +version = "1.0.0b8" initpkg(__name__, description = "py.test and pylib: advanced testing tool and networking lib", diff --git a/py/test/plugin/pytest_restdoc.py b/py/test/plugin/pytest_restdoc.py index 9b0e91b55..baaeb6b98 100644 --- a/py/test/plugin/pytest_restdoc.py +++ b/py/test/plugin/pytest_restdoc.py @@ -362,6 +362,7 @@ def test_deindent(): class TestApigenLinkRole: disabled = True + # these tests are moved here from the former py/doc/conftest.py def test_resolve_linkrole(self): from py.__.doc.conftest import get_apigen_relpath diff --git a/py/test/plugin/pytest_runner.py b/py/test/plugin/pytest_runner.py index 5358066c2..fcb16573b 100644 --- a/py/test/plugin/pytest_runner.py +++ b/py/test/plugin/pytest_runner.py @@ -1,9 +1,5 @@ """ - collect and run test items. - - * executing test items - * running collectors - * and generating report events about it +collect and run test items and creating reports. """ import py @@ -53,7 +49,7 @@ def runtestprotocol(item, log=True): reports = [rep] if rep.passed: reports.append(call_and_report(item, "call", log)) - reports.append(call_and_report(item, "teardown", log)) + reports.append(call_and_report(item, "teardown", log)) return reports def pytest_runtest_setup(item): @@ -225,11 +221,14 @@ class SetupState(object): colitem = self.stack.pop() self._teardown_with_finalization(colitem) - def _teardown_with_finalization(self, colitem): + def _callfinalizers(self, colitem): finalizers = self._finalizers.pop(colitem, None) while finalizers: fin = finalizers.pop() fin() + + def _teardown_with_finalization(self, colitem): + self._callfinalizers(colitem) if colitem: colitem.teardown() for colitem in self._finalizers: @@ -242,17 +241,19 @@ class SetupState(object): assert not self._finalizers def teardown_exact(self, item): - assert self.stack and self.stack[-1] == item - self._pop_and_teardown() + if item == self.stack[-1]: + self._pop_and_teardown() + else: + self._callfinalizers(item) def prepare(self, colitem): """ setup objects along the collector chain to the test-method - Teardown any unneccessary previously setup objects.""" + and teardown previously setup objects.""" needed_collectors = colitem.listchain() while self.stack: if self.stack == needed_collectors[:len(self.stack)]: break self._pop_and_teardown() for col in needed_collectors[len(self.stack):]: - self.stack.append(col) col.setup() + self.stack.append(col) diff --git a/py/test/plugin/test_pytest_runner.py b/py/test/plugin/test_pytest_runner.py index 3b82de301..9286cad57 100644 --- a/py/test/plugin/test_pytest_runner.py +++ b/py/test/plugin/test_pytest_runner.py @@ -86,7 +86,8 @@ class BaseFunctionalTests: #assert rep.skipped.reason == "hello" #assert rep.skipped.location.lineno == 3 #assert rep.skipped.location.lineno == 3 - assert len(reports) == 1 + assert len(reports) == 2 + assert reports[1].passed # teardown def test_failure_in_setup_function(self, testdir): reports = testdir.runitem(""" @@ -101,7 +102,7 @@ class BaseFunctionalTests: assert not rep.passed assert rep.failed assert rep.when == "setup" - assert len(reports) == 1 + assert len(reports) == 2 def test_failure_in_teardown_function(self, testdir): reports = testdir.runitem(""" @@ -156,7 +157,7 @@ class BaseFunctionalTests: def test_func(): pass """) - assert len(reports) == 1 + assert len(reports) == 2 rep = reports[0] print rep assert not rep.skipped diff --git a/py/test/testing/test_setup_functional.py b/py/test/plugin/test_pytest_runner_xunit.py similarity index 99% rename from py/test/testing/test_setup_functional.py rename to py/test/plugin/test_pytest_runner_xunit.py index a8d17e45a..4ecf08d5c 100644 --- a/py/test/testing/test_setup_functional.py +++ b/py/test/plugin/test_pytest_runner_xunit.py @@ -55,6 +55,7 @@ def test_class_setup(testdir): """) reprec.assertoutcome(passed=1+2+1) + def test_method_setup(testdir): reprec = testdir.inline_runsource(""" class TestSetupMethod: diff --git a/py/test/testing/test_pluginmanager.py b/py/test/testing/test_pluginmanager.py index b1fc23f28..bec5d3fe9 100644 --- a/py/test/testing/test_pluginmanager.py +++ b/py/test/testing/test_pluginmanager.py @@ -221,30 +221,6 @@ class TestPytestPluginInteractions: assert not pluginmanager.listattr("hello") assert pluginmanager.listattr("x") == [42] - @py.test.mark.xfail # setup call methods - def test_call_setup_participants(self, testdir): - testdir.makepyfile( - conftest=""" - import py - def pytest_method(self, x): - return x+1 - pytest_plugin = "pytest_someplugin", - """ - ) - testdir.makepyfile(pytest_someplugin=""" - def pytest_method(self, x): - return x+1 - """) - modcol = testdir.getmodulecol(""" - def pytest_method(x): - return x+0 - """) - l = [] - call = modcol.config.pluginmanager.setupcall(modcol, "pytest_method", 1) - assert len(call.methods) == 3 - results = call.execute() - assert results == [1,2,2] - def test_collectattr(): class A: def pytest_hello(self): diff --git a/py/test/testing/test_pycollect.py b/py/test/testing/test_pycollect.py index 2a6c44463..e2dc190a8 100644 --- a/py/test/testing/test_pycollect.py +++ b/py/test/testing/test_pycollect.py @@ -39,6 +39,7 @@ class TestModule: modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',") py.test.raises(ImportError, "modcol.obj") +class TestDisabled: def test_disabled_module(self, testdir): modcol = testdir.getmodulecol(""" disabled = True @@ -51,7 +52,6 @@ class TestModule: assert len(l) == 1 py.test.raises(Skipped, "modcol.setup()") -class TestClass: def test_disabled_class(self, testdir): modcol = testdir.getmodulecol(""" class TestClass: @@ -67,6 +67,15 @@ class TestClass: assert len(l) == 1 py.test.raises(Skipped, "modcol.setup()") + def test_disabled_class_functional(self, testdir): + reprec = testdir.inline_runsource(""" + class TestSimpleClassSetup: + disabled = True + def test_classlevel(self): pass + def test_classlevel2(self): pass + """) + reprec.assertoutcome(skipped=2) + class TestGenerator: def test_generative_functions(self, testdir): modcol = testdir.getmodulecol(""" diff --git a/setup.py b/setup.py index 3adf30e07..726a4ea47 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ """ -autogenerated by gensetup.py - +py lib / py.test setup.py file, autogenerated by gensetup.py + """ import os, sys @@ -30,7 +30,7 @@ def main(): name='py', description='py.test and pylib: advanced testing tool and networking lib', long_description = long_description, - version='1.0.0b7', + version='1.0.0b8', url='http://pylib.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], @@ -144,4 +144,4 @@ def main(): if __name__ == '__main__': main() - + \ No newline at end of file