Skip to content
Draft
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
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ The plugin is available also for tox 4. Differences in behavior between tox 3 an
- The plugin does not check the requested Python version nor the environment name.
If you let it run for multiple environments they'll all use the same Python.
- Deprecated ``--print-deps-only`` option is no longer available.
- Unlike tox 3, tox 4 can normally run without any tox configuration.
When tox 4 runs with ``--print-deps-to`` or ``--print-extras-to`` without a tox configuration, it will fail.
This was deliberately done to make Fedora packages misusing this option fail to build.

Use an isolated environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 5 additions & 0 deletions src/tox_current_env/hooks4.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def tox_add_option(parser):
@impl
def tox_add_core_config(core_conf, state):
opt = state.conf.options
if (opt.print_deps_to or opt.print_extras_to) and not core_conf.loaders:
raise RuntimeError(
"--print-deps-to and/or --print-extras-to cannot be used without a tox config. "
"Seeing this error indicates this project either does not use tox at all or the tox configuration is missing."
)

if opt.current_env or opt.print_deps_to or opt.print_extras_to:
# We do not want to install the main package.
Expand Down
21 changes: 21 additions & 0 deletions tests/test_integration_tox4.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,24 @@ def test_report_installed(projdir):
assert result.returncode == 0
assert "tox==" in result.stdout
assert "pytest==" in result.stdout


@pytest.mark.parametrize("toxenv", envs_from_tox_ini())
def test_print_deps_without_config_fails(projdir, toxenv, print_deps_stdout_arg):
tox_ini = projdir / "tox.ini"
tox_ini.unlink()
# note: tox will traverse the filesystem up to find a config,
# so if this (or the next) test fails,
# check if you don't have a stray tox.ini in /tmp
result = tox("-e", toxenv, print_deps_stdout_arg, check=False)
assert result.returncode > 0
assert "tox configuration is missing" in result.stderr


@pytest.mark.parametrize("toxenv", envs_from_tox_ini())
def test_print_extras_without_config_fails(projdir, toxenv):
tox_ini = projdir / "tox.ini"
tox_ini.unlink()
result = tox("-e", toxenv, "--print-extras-to=-", check=False)
assert result.returncode > 0
assert "tox configuration is missing" in result.stderr