diff options
Diffstat (limited to 'tests/languages')
-rw-r--r-- | tests/languages/conda_test.py | 38 | ||||
-rw-r--r-- | tests/languages/helpers_test.py | 4 |
2 files changed, 40 insertions, 2 deletions
diff --git a/tests/languages/conda_test.py b/tests/languages/conda_test.py new file mode 100644 index 0000000..6faa78f --- /dev/null +++ b/tests/languages/conda_test.py @@ -0,0 +1,38 @@ +import pytest + +from pre_commit import envcontext +from pre_commit.languages.conda import _conda_exe + + +@pytest.mark.parametrize( + ('ctx', 'expected'), + ( + pytest.param( + ( + ('PRE_COMMIT_USE_MICROMAMBA', envcontext.UNSET), + ('PRE_COMMIT_USE_MAMBA', envcontext.UNSET), + ), + 'conda', + id='default', + ), + pytest.param( + ( + ('PRE_COMMIT_USE_MICROMAMBA', '1'), + ('PRE_COMMIT_USE_MAMBA', ''), + ), + 'micromamba', + id='default', + ), + pytest.param( + ( + ('PRE_COMMIT_USE_MICROMAMBA', ''), + ('PRE_COMMIT_USE_MAMBA', '1'), + ), + 'mamba', + id='default', + ), + ), +) +def test_conda_exe(ctx, expected): + with envcontext.envcontext(ctx): + assert _conda_exe() == expected diff --git a/tests/languages/helpers_test.py b/tests/languages/helpers_test.py index 669cd33..fd9b9a4 100644 --- a/tests/languages/helpers_test.py +++ b/tests/languages/helpers_test.py @@ -72,8 +72,8 @@ def test_basic_healthy(): def test_failed_setup_command_does_not_unicode_error(): script = ( 'import sys\n' - "getattr(sys.stderr, 'buffer', sys.stderr).write(b'\\x81\\xfe')\n" - 'exit(1)\n' + "sys.stderr.buffer.write(b'\\x81\\xfe')\n" + 'raise SystemExit(1)\n' ) # an assertion that this does not raise `UnicodeError` |