summaryrefslogtreecommitdiffstats
path: root/tests/languages
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-21 19:59:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-21 19:59:19 +0000
commitf280995a847850327b1a156bfba2068966b1acec (patch)
tree88a9d713cfdba9d743dfead659531357af244b8b /tests/languages
parentReleasing debian version 2.16.0-1. (diff)
downloadpre-commit-f280995a847850327b1a156bfba2068966b1acec.tar.xz
pre-commit-f280995a847850327b1a156bfba2068966b1acec.zip
Merging upstream version 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`