Skip to content

Commit 7140ef8

Browse files
authored
Allow true separation of environment setup and test run (#1606)
By allowing to escape the package build and install upon passing in the `--skip-pkg-install`` flag. Signed-off-by: Bernat Gabor <[email protected]>
1 parent 9f49997 commit 7140ef8

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

docs/changelog/1605.feature.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
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:
2+
3+
.. code-block:: console
4+
5+
tox -e py --notest
6+
tox -e py --skip-pkg-install
7+
8+
by :user:`gaborbernat`.

src/tox/config/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ def tox_addoption(parser):
447447
parser.add_argument(
448448
"--sdistonly", action="store_true", help="only perform the sdist packaging activity.",
449449
)
450+
parser.add_argument(
451+
"--skip-pkg-install", action="store_true", help="skip package installation for this run",
452+
)
450453
add_parallel_flags(parser)
451454
parser.add_argument(
452455
"--parallel--safe-build",
@@ -661,10 +664,14 @@ def merge_description(testenv_config, value):
661664

662665
parser.add_testenv_attribute_obj(PosargsOption())
663666

667+
def skip_install_default(testenv_config, value):
668+
return value is True or testenv_config.config.option.skip_pkg_install is True
669+
664670
parser.add_testenv_attribute(
665671
name="skip_install",
666672
type="bool",
667673
default=False,
674+
postprocess=skip_install_default,
668675
help="Do not install the current package. This can be used when you need the virtualenv "
669676
"management but do not want to install the current package",
670677
)

tests/unit/config/test_config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3121,3 +3121,19 @@ def test_config_no_version_data_in__name(newconfig, capsys):
31213121
out, err = capsys.readouterr()
31223122
assert not out
31233123
assert not err
3124+
3125+
3126+
def test_overwrite_skip_install_override(newconfig):
3127+
source = """
3128+
[tox]
3129+
envlist = py, skip
3130+
[testenv:skip]
3131+
skip_install = True
3132+
"""
3133+
config = newconfig(args=[], source=source)
3134+
assert config.envconfigs["py"].skip_install is False # by default do not skip
3135+
assert config.envconfigs["skip"].skip_install is True
3136+
3137+
config = newconfig(args=["--skip-pkg-install"], source=source)
3138+
assert config.envconfigs["py"].skip_install is True # skip if the flag is passed
3139+
assert config.envconfigs["skip"].skip_install is True

0 commit comments

Comments
 (0)