summaryrefslogtreecommitdiffstats
path: root/tests/languages
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-21 19:59:08 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-21 19:59:08 +0000
commit20ff60e9f0e8528b00b03e036fa3d41743d53dfa (patch)
tree7baccf4096b08411ca191790015c7f6c835a85c7 /tests/languages
parentAdding upstream version 2.16.0. (diff)
downloadpre-commit-20ff60e9f0e8528b00b03e036fa3d41743d53dfa.tar.xz
pre-commit-20ff60e9f0e8528b00b03e036fa3d41743d53dfa.zip
Adding upstream version 2.17.0.upstream/2.17.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/languages')
-rw-r--r--tests/languages/conda_test.py38
-rw-r--r--tests/languages/helpers_test.py4
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`