Skip to content

Commit

Permalink
Remove deprecated cmd options Fixes #1657
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBeardCode committed Jun 25, 2016
1 parent 0c63762 commit 8617764
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 304 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@

*

*
**Incompatible changes**

* Removing the following deprecated commandline options

* genscript
* no-assert
* nomagic
* report

Thanks to `@RedBeardCode`_ for the PR(`#1664`_)



.. _#1580: https://github.com/pytest-dev/pytest/pull/1580
.. _#1605: https://github.com/pytest-dev/pytest/issues/1605
Expand All @@ -47,6 +58,7 @@
.. _#1553: https://github.com/pytest-dev/pytest/issues/1553
.. _#1626: https://github.com/pytest-dev/pytest/pull/1626
.. _#1503: https://github.com/pytest-dev/pytest/issues/1503
.. _#1664: https://github.com/pytest-dev/pytest/pull/1664

.. _@graingert: https://github.com/graingert
.. _@taschini: https://github.com/taschini
Expand Down
11 changes: 0 additions & 11 deletions _pytest/assertion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ def pytest_addoption(parser):
'rewrite' (the default) rewrites assert
statements in test modules on import to
provide assert expression information. """)
group.addoption('--no-assert',
action="store_true",
default=False,
dest="noassert",
help="DEPRECATED equivalent to --assert=plain")
group.addoption('--nomagic', '--no-magic',
action="store_true",
default=False,
help="DEPRECATED equivalent to --assert=plain")


class AssertionState:
Expand All @@ -44,8 +35,6 @@ def __init__(self, config, mode):

def pytest_configure(config):
mode = config.getvalue("assertmode")
if config.getvalue("noassert") or config.getvalue("nomagic"):
mode = "plain"
if mode == "rewrite":
try:
import ast # noqa
Expand Down
40 changes: 0 additions & 40 deletions _pytest/genscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,46 +52,6 @@ def compress_packages(names):
mapping.update(pkg_to_mapping(name))
return compress_mapping(mapping)

def generate_script(entry, packages):
data = compress_packages(packages)
tmpl = py.path.local(__file__).dirpath().join('standalonetemplate.py')
exe = tmpl.read()
exe = exe.replace('@SOURCES@', data)
exe = exe.replace('@ENTRY@', entry)
return exe


def pytest_addoption(parser):
group = parser.getgroup("debugconfig")
group.addoption("--genscript", action="store", default=None,
dest="genscript", metavar="path",
help="create standalone pytest script at given target path.")

def pytest_cmdline_main(config):
import _pytest.config
genscript = config.getvalue("genscript")
if genscript:
tw = _pytest.config.create_terminal_writer(config)
tw.line("WARNING: usage of genscript is deprecated.",
red=True)
deps = ['py', '_pytest', 'pytest'] # pluggy is vendored
if sys.version_info < (2,7):
deps.append("argparse")
tw.line("generated script will run on python2.6-python3.3++")
else:
tw.line("WARNING: generated script will not run on python2.6 "
"due to 'argparse' dependency. Use python2.6 "
"to generate a python2.6 compatible script", red=True)
script = generate_script(
'import pytest; raise SystemExit(pytest.cmdline.main())',
deps,
)
genscript = py.path.local(genscript)
genscript.write(script)
tw.line("generated pytest standalone script: %s" % genscript,
bold=True)
return 0


def pytest_namespace():
return {'freeze_includes': freeze_includes}
Expand Down
89 changes: 0 additions & 89 deletions _pytest/standalonetemplate.py

This file was deleted.

14 changes: 0 additions & 14 deletions _pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ def pytest_addoption(parser):
group._addoption('-l', '--showlocals',
action="store_true", dest="showlocals", default=False,
help="show locals in tracebacks (disabled by default).")
group._addoption('--report',
action="store", dest="report", default=None, metavar="opts",
help="(deprecated, use -r)")
group._addoption('--tb', metavar="style",
action="store", dest="tbstyle", default='auto',
choices=['auto', 'long', 'short', 'no', 'line', 'native'],
Expand All @@ -54,17 +51,6 @@ def mywriter(tags, args):

def getreportopt(config):
reportopts = ""
optvalue = config.option.report
if optvalue:
py.builtin.print_("DEPRECATED: use -r instead of --report option.",
file=sys.stderr)
if optvalue:
for setting in optvalue.split(","):
setting = setting.strip()
if setting == "skipped":
reportopts += "s"
elif setting == "xfailed":
reportopts += "x"
reportchars = config.option.reportchars
if reportchars:
for char in reportchars:
Expand Down
3 changes: 3 additions & 0 deletions doc/en/assert.rst
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,6 @@ For further information, Benjamin Peterson wrote up `Behind the scenes of pytest
.. versionchanged:: 2.1
Introduce the ``--assert`` option. Deprecate ``--no-assert`` and
``--nomagic``.

.. versionchanged:: 3.0
Removes the ``--no-assert`` and``--nomagic`` options.
7 changes: 1 addition & 6 deletions doc/en/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Where to go next
Here are a few suggestions where to go next:

* :ref:`cmdline` for command line invocation examples
* :ref:`good practices <goodpractices>` for virtualenv, test layout, genscript support
* :ref:`good practices <goodpractices>` for virtualenv, test layout
* :ref:`fixtures` for providing a functional baseline to your tests
* :ref:`apiref` for documentation and examples on using ``pytest``
* :ref:`plugins` managing and writing plugins
Expand Down Expand Up @@ -227,11 +227,6 @@ py.test not found on Windows despite installation?

.. _`Jython does not create command line launchers`: http://bugs.jython.org/issue1491

- **Jython2.5.1 on Windows XP**: `Jython does not create command line launchers`_
so ``py.test`` will not work correctly. You may install py.test on
CPython and type ``py.test --genscript=mytest`` and then use
``jython mytest`` to run your tests with Jython using ``pytest``.

:ref:`examples` for more complex examples

.. include:: links.inc
33 changes: 0 additions & 33 deletions doc/en/goodpractices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -243,38 +243,5 @@ using the ``--pytest-args`` or ``-a`` command-line option. For example::
is equivalent to running ``py.test --durations=5``.


.. _standalone:
.. _`genscript method`:

(deprecated) Create a pytest standalone script
-----------------------------------------------

.. deprecated:: 2.8

.. note::

``genscript`` has been deprecated because:

* It cannot support plugins, rendering its usefulness extremely limited;
* Tooling has become much better since ``genscript`` was introduced;
* It is possible to build a zipped ``pytest`` application without the
shortcomings above.

There's no planned version in which this command will be removed
at the moment of this writing, but its use is discouraged for new
applications.

If you are a maintainer or application developer and want people
who don't deal with python much to easily run tests you may generate
a standalone ``pytest`` script::

py.test --genscript=runtests.py

This generates a ``runtests.py`` script which is a fully functional basic
``pytest`` script, running unchanged under Python2 and Python3.
You can tell people to download the script and then e.g. run it like this::

python runtests.py


.. include:: links.inc
1 change: 0 additions & 1 deletion doc/en/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ in the `pytest repository <https://github.com/pytest-dev/pytest>`_.
_pytest.capture
_pytest.config
_pytest.doctest
_pytest.genscript
_pytest.helpconfig
_pytest.junitxml
_pytest.mark
Expand Down
28 changes: 0 additions & 28 deletions doc/en/test/plugin/genscript.rst

This file was deleted.

2 changes: 0 additions & 2 deletions doc/en/test/plugin/helpconfig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ command line options
early-load given plugin (multi-allowed).
``--trace-config``
trace considerations of conftest.py files.
``--nomagic``
don't reinterpret asserts, no traceback cutting.
``--debug``
generate and show internal debugging information.
``--help-config``
Expand Down
2 changes: 0 additions & 2 deletions doc/en/test/plugin/links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
.. _`pytest_recwarn.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.3.4/py/_plugin/pytest_recwarn.py
.. _`unittest`: unittest.html
.. _`pytest_monkeypatch.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.3.4/py/_plugin/pytest_monkeypatch.py
.. _`pytest_genscript.py`: http://bitbucket.org/hpk42/py-trunk/raw/1.3.4/py/_plugin/pytest_genscript.py
.. _`pastebin`: pastebin.html
.. _`skipping`: skipping.html
.. _`genscript`: genscript.html
.. _`plugins`: index.html
.. _`mark`: mark.html
.. _`tmpdir`: tmpdir.html
Expand Down
2 changes: 0 additions & 2 deletions doc/en/test/plugin/terminal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ command line options
show extra test summary info as specified by chars (f)ailed, (s)skipped, (x)failed, (X)passed.
``-l, --showlocals``
show locals in tracebacks (disabled by default).
``--report=opts``
(deprecated, use -r)
``--tb=style``
traceback print mode (long/short/line/no).
``--full-trace``
Expand Down
14 changes: 3 additions & 11 deletions testing/test_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,16 +474,8 @@ def test_hello():
""")
result = testdir.runpytest()
assert "3 == 4" in result.stdout.str()
off_options = (("--no-assert",),
("--nomagic",),
("--no-assert", "--nomagic"),
("--assert=plain",),
("--assert=plain", "--no-assert"),
("--assert=plain", "--nomagic"),
("--assert=plain", "--no-assert", "--nomagic"))
for opt in off_options:
result = testdir.runpytest_subprocess(*opt)
assert "3 == 4" not in result.stdout.str()
result = testdir.runpytest_subprocess("--assert=plain")
assert "3 == 4" not in result.stdout.str()

def test_old_assert_mode(testdir):
testdir.makepyfile("""
Expand Down Expand Up @@ -559,7 +551,7 @@ def test_warn_missing(testdir):
result.stderr.fnmatch_lines([
"*WARNING*assert statements are not executed*",
])
result = testdir.run(sys.executable, "-OO", "-m", "pytest", "--no-assert")
result = testdir.run(sys.executable, "-OO", "-m", "pytest")
result.stderr.fnmatch_lines([
"*WARNING*assert statements are not executed*",
])
Expand Down
2 changes: 1 addition & 1 deletion testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def test_f2(): assert 0
""")

for opts in ([], ['-l'], ['-s'], ['--tb=no'], ['--tb=short'],
['--tb=long'], ['--fulltrace'], ['--nomagic'],
['--tb=long'], ['--fulltrace'],
['--traceconfig'], ['-v'], ['-v', '-v']):
runfiletest(opts + [path])

Expand Down
Loading

0 comments on commit 8617764

Please sign in to comment.