-
Notifications
You must be signed in to change notification settings - Fork 444
Fix xonsh
#4366
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
base: main
Are you sure you want to change the base?
Fix xonsh
#4366
Changes from all commits
bb7bc07
f65f8c6
f5697ee
5345c5c
17e6a6d
6a90761
f815f3a
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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import os | ||
| import pathlib | ||
| import platform | ||
| import re | ||
| import shutil | ||
| import subprocess | ||
| import tempfile | ||
|
|
@@ -933,6 +934,67 @@ def test_activate_envs_dirs( | |
| assert any([env_name in p for p in dict_res.values()]) | ||
|
|
||
|
|
||
| @pytest.mark.skipif( | ||
| "xonsh" not in valid_interpreters, | ||
| reason="xonsh not available", | ||
| ) | ||
| @pytest.mark.parametrize("alias", ["micromamba", "mamba"]) | ||
| def test_xonsh_help_and_version(tmp_home, tmp_root_prefix, tmp_path, alias): | ||
| umamba = helpers.get_umamba() | ||
|
|
||
| s = [f"{umamba} shell init -r {tmp_root_prefix} -s xonsh"] | ||
| call_interpreter(s, tmp_path, "xonsh") | ||
|
|
||
| def call(s): | ||
| return call_interpreter(s, tmp_path, "xonsh", interactive=True) | ||
|
|
||
| s = [f"{alias} --help"] | ||
| stdout, stderr = call(s) | ||
| assert not stderr, f"stderr was not empty: {stderr}" | ||
| assert "--help" in stdout | ||
| assert "Print this help message and exit" in stdout | ||
|
|
||
| s = [f"{alias} --version"] | ||
| stdout, stderr = call(s) | ||
| assert not stderr, f"stderr was not empty: {stderr}" | ||
| assert re.search(r"\d+\.\d+\.\d+", stdout.strip()), f"not a version: {stdout}" | ||
|
|
||
|
|
||
| @pytest.mark.skipif( | ||
| "xonsh" not in valid_interpreters, | ||
| reason="xonsh not available", | ||
| ) | ||
| @pytest.mark.parametrize("alias", ["micromamba", "mamba"]) | ||
| def test_xonsh_del_nonexistent_env_var(tmp_home, tmp_root_prefix, tmp_path, alias): | ||
| umamba = helpers.get_umamba() | ||
|
|
||
| s = [f"{umamba} shell init -r {tmp_root_prefix} -s xonsh"] | ||
| call_interpreter(s, tmp_path, "xonsh") | ||
|
|
||
| def call(s): | ||
| return call_interpreter(s, tmp_path, "xonsh", interactive=True) | ||
|
|
||
| helpers.create("-n", "test_unset_env", "--offline", "--no-rc", no_dry_run=True) | ||
|
|
||
| prefix = tmp_root_prefix / "envs" / "test_unset_env" | ||
| state_file = prefix / "conda-meta" / "state" | ||
| state_file.write_text(helpers.json.dumps({"env_vars": {"MAMBA_UNSET_TEST": "hello"}})) | ||
|
|
||
| # activate → manually delete var → deactivate | ||
| s = [ | ||
| f"{alias} activate test_unset_env", | ||
| "del $MAMBA_UNSET_TEST", | ||
| f"{alias} deactivate", | ||
| ] | ||
|
Comment on lines
+983
to
+988
Member
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. Could we also try to use the
Member
Author
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. Hmm not sure I get what you mean. |
||
|
|
||
| try: | ||
| stdout, stderr = call(s) | ||
| except subprocess.CalledProcessError: | ||
| pytest.fail("deactivate crashed on del of non-existent env var") | ||
|
|
||
| assert "does not contain any filesystem separator" not in stderr | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def tmp_umamba(): | ||
| mamba_exe = helpers.get_umamba() | ||
|
|
||
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.
Also do you think that it is possible to test the case where
MAMBA_UNSET_TEST:test_unset_envto "hello"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.
I think that would be testing restoring environment variables behavior with activation and deactivation, and therefore is a more general test.
I suggest to rather open an issue to check the existence of such tests and add them if not.