Skip to content

Allow true separation of environment setup and test run #1606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/changelog/1605.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Allow skipping the package and installation step when passing the ``--skip-pkg-install``. This should be used in pair with the ``--notest``, so you can separate environment setup and test run:

.. code-block:: console

tox -e py --notest
tox -e py --skip-pkg-install

by :user:`gaborbernat`.
7 changes: 7 additions & 0 deletions src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,9 @@ def tox_addoption(parser):
parser.add_argument(
"--sdistonly", action="store_true", help="only perform the sdist packaging activity.",
)
parser.add_argument(
"--skip-pkg-install", action="store_true", help="skip package installation for this run",
)
add_parallel_flags(parser)
parser.add_argument(
"--parallel--safe-build",
Expand Down Expand Up @@ -661,10 +664,14 @@ def merge_description(testenv_config, value):

parser.add_testenv_attribute_obj(PosargsOption())

def skip_install_default(testenv_config, value):
return value is True or testenv_config.config.option.skip_pkg_install is True

parser.add_testenv_attribute(
name="skip_install",
type="bool",
default=False,
postprocess=skip_install_default,
help="Do not install the current package. This can be used when you need the virtualenv "
"management but do not want to install the current package",
)
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3121,3 +3121,19 @@ def test_config_no_version_data_in__name(newconfig, capsys):
out, err = capsys.readouterr()
assert not out
assert not err


def test_overwrite_skip_install_override(newconfig):
source = """
[tox]
envlist = py, skip
[testenv:skip]
skip_install = True
"""
config = newconfig(args=[], source=source)
assert config.envconfigs["py"].skip_install is False # by default do not skip
assert config.envconfigs["skip"].skip_install is True

config = newconfig(args=["--skip-pkg-install"], source=source)
assert config.envconfigs["py"].skip_install is True # skip if the flag is passed
assert config.envconfigs["skip"].skip_install is True