-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
Disallow command line environments which are not explicitly specified in the config file #3089
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Disallow command line environments which are not explicitly specified in the config file - by :user:`tjsmart`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,3 +132,35 @@ def test_env_select_lazily_looks_at_envs() -> None: | |
# late-assigning env should be reflected in env_selector | ||
state.conf.options.env = CliEnv("py") | ||
assert set(env_selector.iter()) == {"py"} | ||
|
||
|
||
def test_cli_env_can_be_specified_in_default(tox_project: ToxProjectCreator) -> None: | ||
proj = tox_project({"tox.ini": "[tox]\nenv_list=exists"}) | ||
outcome = proj.run("r", "-e", "exists") | ||
outcome.assert_success() | ||
assert "exists" in outcome.out | ||
assert not outcome.err | ||
|
||
|
||
def test_cli_env_can_be_specified_in_additional_environments(tox_project: ToxProjectCreator) -> None: | ||
proj = tox_project({"tox.ini": "[testenv:exists]"}) | ||
outcome = proj.run("r", "-e", "exists") | ||
outcome.assert_success() | ||
assert "exists" in outcome.out | ||
assert not outcome.err | ||
|
||
|
||
def test_cli_env_not_in_tox_config_fails(tox_project: ToxProjectCreator) -> None: | ||
proj = tox_project({"tox.ini": ""}) | ||
outcome = proj.run("r", "-e", "does_not_exist") | ||
outcome.assert_failed(code=-2) | ||
assert "provided environments not found in configuration file: ['does_not_exist']" in outcome.out, outcome.out | ||
|
||
|
||
@pytest.mark.parametrize("env_name", ["py", "py310", ".pkg"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR welcome, likely should be pyx.y where x.y is the current Python interpreter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
def test_allowed_implicit_cli_envs(env_name: str, tox_project: ToxProjectCreator) -> None: | ||
proj = tox_project({"tox.ini": ""}) | ||
outcome = proj.run("r", "-e", env_name) | ||
outcome.assert_success() | ||
assert env_name in outcome.out | ||
assert not outcome.err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While in a bit of broken state, this test was hanging for me. Suggesting that we use
Popen.poll
to check if the child process has already terminated (likely with an error if marker does not exist).