Skip to content

Commit

Permalink
Merge pull request #1 from RonnyPfannschmidt/remove-boxed
Browse files Browse the repository at this point in the history
Remove boxed and provide --boxed via pytest-forked
  • Loading branch information
nicoddemus committed Aug 5, 2017
2 parents 1d631ca + c454d41 commit fbe793e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 133 deletions.
2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ test execution modes:
those for a combined test run. This allows to speed up
development or to use special resources of `remote machines`_.

* ``--boxed``: (not available on Windows) run each test in a boxed_
subprocess to survive ``SEGFAULTS`` or otherwise dying processes

* ``--looponfail``: run your tests repeatedly in a subprocess. After each run
py.test waits until a file in your project changes and then re-runs
Expand Down
1 change: 1 addition & 0 deletions changelog/1.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``--boxed`` functionality has been moved to a separate plugin, `pytest-forked <https://github.com/pytest-dev/pytest-forked>`_. This release now depends on `` pytest-forked`` and provides ``--boxed`` as a backward compatibility option.
18 changes: 12 additions & 6 deletions example/boxed.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.. note::

Since 1.19.0, the actual implementation of the ``--boxed`` option has been moved to a
separate plugin, `pytest-forked <https://github.com/pytest-dev/pytest-forked>`_
which can be installed independently. The ``--boxed`` command-line options remains
for backward compatibility reasons.


If your testing involves C or C++ libraries you might have to deal
Expand All @@ -14,19 +20,19 @@ to run each test in a controlled subprocess. Here is a basic example::
@pytest.mark.parametrize("arg", range(50))
def test_func(arg):
time.sleep(0.05) # each tests takes a while
if arg % 19 == 0:
if arg % 19 == 0:
os.kill(os.getpid(), 15)

If you run this with::

$ py.test --boxed
$ py.test -n1
=========================== 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
Expand All @@ -40,13 +46,13 @@ 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
$ py.test -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 =================================
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import setup, find_packages

install_requires = ['execnet>=1.1', 'pytest>=3.0.0']
install_requires = ['execnet>=1.1', 'pytest>=3.0.0', 'pytest-forked']

if version_info < (2, 7):
install_requires.append('ordereddict')
Expand All @@ -24,7 +24,6 @@
'pytest11': [
'xdist = xdist.plugin',
'xdist.looponfail = xdist.looponfail',
'xdist.boxed = xdist.boxed',
],
},
zip_safe=False,
Expand Down
58 changes: 0 additions & 58 deletions testing/test_boxed.py

This file was deleted.

60 changes: 0 additions & 60 deletions xdist/boxed.py

This file was deleted.

16 changes: 11 additions & 5 deletions xdist/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def pytest_addoption(parser):
help="shortcut for '--dist=load --tx=NUM*popen', "
"you can use 'auto' here for auto detection CPUs number on "
"host system")
group._addoption('--max-slave-restart', action="store", default=None,
help="maximum number of slaves that can be restarted "
"when crashed (set to zero to disable this feature)")
group._addoption(
group.addoption('--max-slave-restart', action="store", default=None,
help="maximum number of slaves that can be restarted "
"when crashed (set to zero to disable this feature)")
group.addoption(
'--dist', metavar="distmode",
action="store", choices=['each', 'load', 'loadscope', 'no'],
dest="dist", default="no",
Expand All @@ -40,7 +40,7 @@ def pytest_addoption(parser):
"loadscope: load balance by sending pending groups of tests in"
" the same scope to any available environment.\n\n"
"(default) no: run tests inprocess, don't distribute."))
group._addoption(
group.addoption(
'--tx', dest="tx", action="append", default=[],
metavar="xspec",
help=("add a test execution environment. some examples: "
Expand All @@ -57,6 +57,9 @@ def pytest_addoption(parser):
'--rsyncignore', action="append", default=[], metavar="GLOB",
help="add expression for ignores when rsyncing to remote tx nodes.")

group.addoption(
"--boxed", action="store_true",
help="backward compatibility alias for pytest-forked --forked")
parser.addini(
'rsyncdirs', 'list of (relative) paths to be rsynced for'
' remote distributed testing.', type="pathlist")
Expand All @@ -67,6 +70,7 @@ def pytest_addoption(parser):
"looponfailroots", type="pathlist",
help="directories to check for changes", default=[py.path.local()])


# -------------------------------------------------------------------------
# distributed testing hooks
# -------------------------------------------------------------------------
Expand All @@ -93,6 +97,8 @@ def pytest_configure(config):
config.pluginmanager.register(session, "dsession")
tr = config.pluginmanager.getplugin("terminalreporter")
tr.showfspath = False
if config.getoption("boxed"):
config.option.forked = True


@pytest.mark.tryfirst
Expand Down

0 comments on commit fbe793e

Please sign in to comment.