From f25771a1016a3c503528b2e7234332494b09a31c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 16 Aug 2016 20:22:15 -0300 Subject: [PATCH] Deprecate --resultlog cmdline option Fix #830 --- CHANGELOG.rst | 13 +++++++++++-- _pytest/deprecated.py | 1 + _pytest/resultlog.py | 5 ++++- doc/en/usage.rst | 4 ++++ testing/deprecated_test.py | 12 ++++++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fd5850299..4fb0c07ce 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -274,8 +274,16 @@ time or change existing behaviors in order to make them less surprising/more use Thanks `@BeyondEvil`_ for reporting `#1210`_. Thanks to `@JonathonSonesen`_ and `@tomviner`_ for the PR. -* fix `#1372`_ no longer display the incorrect test deselection reason, - thanks `@ronnypfannschmidt`_ for the PR. +* No longer display the incorrect test deselection reason (`#1372`_). + Thanks `@ronnypfannschmidt`_ for the PR. + +* The ``--resultlog`` command line option has been deprecated: it is little used + and there are more modern and better alternatives (see `#830`_). + Thanks `@nicoddemus`_ for the PR. + +* + +* * @@ -377,6 +385,7 @@ time or change existing behaviors in order to make them less surprising/more use .. _#607: https://github.com/pytest-dev/pytest/issues/607 .. _#634: https://github.com/pytest-dev/pytest/issues/634 .. _#717: https://github.com/pytest-dev/pytest/issues/717 +.. _#830: https://github.com/pytest-dev/pytest/issues/830 .. _#925: https://github.com/pytest-dev/pytest/issues/925 diff --git a/_pytest/deprecated.py b/_pytest/deprecated.py index 2972c77a5..7d8c747af 100644 --- a/_pytest/deprecated.py +++ b/_pytest/deprecated.py @@ -19,3 +19,4 @@ FUNCARG_PREFIX = ( GETFUNCARGVALUE = "use of getfuncargvalue is deprecated, use getfixturevalue" +RESULT_LOG = '--result-log is deprecated and scheduled for removal in pytest 4.0' diff --git a/_pytest/resultlog.py b/_pytest/resultlog.py index 3670f0214..fc0025983 100644 --- a/_pytest/resultlog.py +++ b/_pytest/resultlog.py @@ -9,7 +9,7 @@ def pytest_addoption(parser): group = parser.getgroup("terminal reporting", "resultlog plugin options") group.addoption('--resultlog', '--result-log', action="store", metavar="path", default=None, - help="path for machine-readable result log.") + help="DEPRECATED path for machine-readable result log.") def pytest_configure(config): resultlog = config.option.resultlog @@ -22,6 +22,9 @@ def pytest_configure(config): config._resultlog = ResultLog(config, logfile) config.pluginmanager.register(config._resultlog) + from _pytest.deprecated import RESULT_LOG + config.warn('C1', RESULT_LOG) + def pytest_unconfigure(config): resultlog = getattr(config, '_resultlog', None) if resultlog: diff --git a/doc/en/usage.rst b/doc/en/usage.rst index d056abd01..f87e1496d 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -251,6 +251,10 @@ This will add a property node below the testsuite node to the generated xml: Creating resultlog format files ---------------------------------------------------- +.. deprecated:: 3.0 + + This option is rarely used and is scheduled for removal in 4.0. + To create plain-text machine-readable result files you can issue:: pytest --resultlog=path diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index edbd5d1cd..87869bcf2 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -53,3 +53,15 @@ def test_str_args_deprecated(tmpdir, testdir): def test_getfuncargvalue_is_deprecated(request): pytest.deprecated_call(request.getfuncargvalue, 'tmpdir') + + +def test_resultlog_is_deprecated(testdir): + result = testdir.runpytest('--help') + result.stdout.fnmatch_lines(['*DEPRECATED path for machine-readable result log*']) + + testdir.makepyfile(''' + def test(): + pass + ''') + result = testdir.runpytest('--result-log=%s' % testdir.tmpdir.join('result.log')) + result.stdout.fnmatch_lines(['*--result-log is deprecated and scheduled for removal in pytest 4.0*'])