From 2c7d00579b952fb3ac6d3d95161ca15f23bc04f0 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 30 Sep 2013 16:09:26 +0200 Subject: [PATCH] bump version, some windows test fixes, prevent logging from raising exceptions at the end (finally), add py25 to tox.ini. --- CHANGELOG | 61 ++++++++++++++++++++------------------ _pytest/__init__.py | 2 +- _pytest/capture.py | 5 ++++ setup.py | 2 +- testing/acceptance_test.py | 10 +++---- testing/test_capture.py | 1 - tox.ini | 2 +- 7 files changed, 45 insertions(+), 38 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 49212fcb1..9b68cf361 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,22 +14,23 @@ known incompatibilities: - the pytest_plugin_unregister hook wasn't ever properly called and there is no known implementation of the hook - so it got removed. -- pytest.fixture-decorated functions cannot be generators (i.e. use yield) anymore. - This change might be reversed in 2.4.1 if it causes unforeseen real-life issues. - However, you can always write and return an inner function/generator - and change the fixture consumer to iterate over the returned generator. - This change was done in lieu of the new ``pytest.yield_fixture`` decorator, see below. +- pytest.fixture-decorated functions cannot be generators (i.e. use + yield) anymore. This change might be reversed in 2.4.1 if it causes + unforeseen real-life issues. However, you can always write and return + an inner function/generator and change the fixture consumer to iterate + over the returned generator. This change was done in lieu of the new + ``pytest.yield_fixture`` decorator, see below. new features: -- experimentally introduce a new ``pytest.yield_fixture`` decorator which - accepts exactly the same parameters as pytest.fixture but mandates - a ``yield`` statement instead of a ``return statement`` from fixture functions. - This allows direct integration with "with-style" context managers - in fixture functions and generally avoids registering of finalization callbacks - in favour of treating the "after-yield" as teardown code. - Thanks Andreas Pelme, Vladimir Keleshev, Floris Bruynooghe, Ronny Pfannschmidt - and many others for discussions. +- experimentally introduce a new ``pytest.yield_fixture`` decorator + which accepts exactly the same parameters as pytest.fixture but + mandates a ``yield`` statement instead of a ``return statement`` from + fixture functions. This allows direct integration with "with-style" + context managers in fixture functions and generally avoids registering + of finalization callbacks in favour of treating the "after-yield" as + teardown code. Thanks Andreas Pelme, Vladimir Keleshev, Floris + Bruynooghe, Ronny Pfannschmidt and many others for discussions. - allow boolean expression directly with skipif/xfail if a "reason" is also specified. Rework skipping documentation @@ -37,11 +38,12 @@ new features: when importing markers between modules. Specifying conditions as strings will remain fully supported. -- reporting: color the last line red or green depending if failures/errors occured - or everything passed. thanks Christian Theunert. +- reporting: color the last line red or green depending if + failures/errors occured or everything passed. thanks Christian + Theunert. -- make "import pdb ; pdb.set_trace()" work natively wrt capturing (no "-s" needed - anymore), making ``pytest.set_trace()`` a mere shortcut. +- make "import pdb ; pdb.set_trace()" work natively wrt capturing (no + "-s" needed anymore), making ``pytest.set_trace()`` a mere shortcut. - fix issue181: --pdb now also works on collect errors (and on internal errors) . This was implemented by a slight internal @@ -59,13 +61,14 @@ new features: will replace the "get" function of the "requests" module with ``myfunc``. - fix issue322: tearDownClass is not run if setUpClass failed. Thanks - Mathieu Agopian for the initial fix. Also make all of pytest/nose finalizer - mimick the same generic behaviour: if a setupX exists and fails, - don't run teardownX. This internally introduces a new method "node.addfinalizer()" - helper which can only be called during the setup phase of a node. + Mathieu Agopian for the initial fix. Also make all of pytest/nose + finalizer mimick the same generic behaviour: if a setupX exists and + fails, don't run teardownX. This internally introduces a new method + "node.addfinalizer()" helper which can only be called during the setup + phase of a node. -- simplify pytest.mark.parametrize() signature: allow to pass a CSV-separated string - to specify argnames. For example: +- simplify pytest.mark.parametrize() signature: allow to pass a + CSV-separated string to specify argnames. For example: ``pytest.mark.parametrize("input,expected", [(1,2), (2,3)])`` works as well as the previous: ``pytest.mark.parametrize(("input", "expected"), ...)``. @@ -75,11 +78,12 @@ new features: - integrate tab-completion on options through use of "argcomplete". Thanks Anthon van der Neut for the PR. -- change option names to be hyphen-separated long options but keep the old spelling - backward compatible. py.test -h will only show the hyphenated version, - for example "--collect-only" but "--collectonly" will remain valid as well - (for backward-compat reasons). Many thanks to Anthon van der Neut for - the implementation and to Hynek Schlawack for pushing us. +- change option names to be hyphen-separated long options but keep the + old spelling backward compatible. py.test -h will only show the + hyphenated version, for example "--collect-only" but "--collectonly" + will remain valid as well (for backward-compat reasons). Many thanks to + Anthon van der Neut for the implementation and to Hynek Schlawack for + pushing us. - fix issue 308 - allow to mark/xfail/skip individual parameter sets when parametrizing. Thanks Brianna Laugher. @@ -141,7 +145,6 @@ Bug fixes: - fix issue 306 - cleanup of -k/-m options to only match markers/test names/keywords respectively. Thanks Wouter van Ackooy. - - improved doctest counting for doctests in python modules -- files without any doctest items will not show up anymore and doctest examples are counted as separate test items. diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 6f16fe67e..44b29e66f 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.4.0.dev13' +__version__ = '2.4.0.dev14' diff --git a/_pytest/capture.py b/_pytest/capture.py index 8fd4cafdf..12291a5e3 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -29,6 +29,11 @@ def pytest_load_initial_conftests(early_config, parser, args, __multicall__): except ValueError: pass early_config.pluginmanager.add_shutdown(teardown) + # make sure logging does not raise exceptions if it is imported + def silence_logging_at_shutdown(): + if "logging" in sys.modules: + sys.modules["logging"].raiseExceptions = False + early_config.pluginmanager.add_shutdown(silence_logging_at_shutdown) # finally trigger conftest loading but while capturing (issue93) capman.resumecapture() diff --git a/setup.py b/setup.py index a5574d061..0b72cbb36 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.4.0.dev13', + version='2.4.0.dev14', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 5ae588760..1abf0dd62 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -586,9 +586,9 @@ class TestDurationWithFixture: result = testdir.runpytest("--durations=10") assert result.ret == 0 - result.stdout.fnmatch_lines([ - "*durations*", - "* setup *test_1*", - "* call *test_1*", - ]) + result.stdout.fnmatch_lines_random(""" + *durations* + * setup *test_1* + * call *test_1* + """) diff --git a/testing/test_capture.py b/testing/test_capture.py index 3fc2404ee..d8271806f 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -437,7 +437,6 @@ class TestCaptureFixture: ]) assert result.ret == 2 - @pytest.mark.xfail("sys.version_info < (2,7)") @pytest.mark.issue14 def test_capture_and_logging(self, testdir): p = testdir.makepyfile(""" diff --git a/tox.ini b/tox.ini index fe0be41c1..76dc15dd6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] distshare={homedir}/.tox/distshare -envlist=py26,py27,py27-nobyte,py32,py33,py27-xdist,trial +envlist=py25,py26,py27,py27-nobyte,py32,py33,py27-xdist,trial [testenv] changedir=testing