summaryrefslogtreecommitdiffstats
path: root/tests/languages
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-04 18:42:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-04-04 18:42:11 +0000
commit361ff4da262b4891323287049e9e6c5fbe1d01dc (patch)
tree969b376a2c170841758d39ef9516dac65c8b94cd /tests/languages
parentAdding upstream version 2.17.0. (diff)
downloadpre-commit-361ff4da262b4891323287049e9e6c5fbe1d01dc.tar.xz
pre-commit-361ff4da262b4891323287049e9e6c5fbe1d01dc.zip
Adding upstream version 2.18.1.upstream/2.18.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/languages')
-rw-r--r--tests/languages/conda_test.py2
-rw-r--r--tests/languages/docker_test.py2
-rw-r--r--tests/languages/golang_test.py2
-rw-r--r--tests/languages/helpers_test.py6
-rw-r--r--tests/languages/node_test.py2
-rw-r--r--tests/languages/pygrep_test.py2
-rw-r--r--tests/languages/python_test.py10
-rw-r--r--tests/languages/r_test.py14
-rw-r--r--tests/languages/ruby_test.py2
9 files changed, 37 insertions, 5 deletions
diff --git a/tests/languages/conda_test.py b/tests/languages/conda_test.py
index 6faa78f..5023b2a 100644
--- a/tests/languages/conda_test.py
+++ b/tests/languages/conda_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import pytest
from pre_commit import envcontext
diff --git a/tests/languages/docker_test.py b/tests/languages/docker_test.py
index ec6bb83..5838761 100644
--- a/tests/languages/docker_test.py
+++ b/tests/languages/docker_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import builtins
import json
import ntpath
diff --git a/tests/languages/golang_test.py b/tests/languages/golang_test.py
index 9a64ed1..9e393cb 100644
--- a/tests/languages/golang_test.py
+++ b/tests/languages/golang_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import pytest
from pre_commit.languages.golang import guess_go_dir
diff --git a/tests/languages/helpers_test.py b/tests/languages/helpers_test.py
index fd9b9a4..259cb97 100644
--- a/tests/languages/helpers_test.py
+++ b/tests/languages/helpers_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import multiprocessing
import os.path
import sys
@@ -86,7 +88,9 @@ def test_assert_no_additional_deps():
helpers.assert_no_additional_deps('lang', ['hmmm'])
msg, = excinfo.value.args
assert msg == (
- 'For now, pre-commit does not support additional_dependencies for lang'
+ 'for now, pre-commit does not support additional_dependencies for '
+ 'lang -- '
+ "you selected `additional_dependencies: ['hmmm']`"
)
diff --git a/tests/languages/node_test.py b/tests/languages/node_test.py
index 8e52268..fb5ae71 100644
--- a/tests/languages/node_test.py
+++ b/tests/languages/node_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import json
import os
import shutil
diff --git a/tests/languages/pygrep_test.py b/tests/languages/pygrep_test.py
index d8bacc4..8420046 100644
--- a/tests/languages/pygrep_test.py
+++ b/tests/languages/pygrep_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import pytest
from pre_commit.languages import pygrep
diff --git a/tests/languages/python_test.py b/tests/languages/python_test.py
index 8324cac..6160669 100644
--- a/tests/languages/python_test.py
+++ b/tests/languages/python_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import os.path
import sys
from unittest import mock
@@ -47,16 +49,16 @@ def test_norm_version_of_default_is_sys_executable():
assert python.norm_version('default') is None
-@pytest.mark.parametrize('v', ('python3.6', 'python3', 'python'))
+@pytest.mark.parametrize('v', ('python3.9', 'python3', 'python'))
def test_sys_executable_matches(v):
- with mock.patch.object(sys, 'version_info', (3, 6, 7)):
+ with mock.patch.object(sys, 'version_info', (3, 9, 10)):
assert python._sys_executable_matches(v)
assert python.norm_version(v) is None
@pytest.mark.parametrize('v', ('notpython', 'python3.x'))
def test_sys_executable_matches_does_not_match(v):
- with mock.patch.object(sys, 'version_info', (3, 6, 7)):
+ with mock.patch.object(sys, 'version_info', (3, 9, 10)):
assert not python._sys_executable_matches(v)
@@ -65,7 +67,7 @@ def test_sys_executable_matches_does_not_match(v):
('/usr/bin/python3', '/usr/bin/python3.7', 'python3'),
('/usr/bin/python', '/usr/bin/python3.7', 'python3.7'),
('/usr/bin/python', '/usr/bin/python', None),
- ('/usr/bin/python3.6m', '/usr/bin/python3.6m', 'python3.6m'),
+ ('/usr/bin/python3.7m', '/usr/bin/python3.7m', 'python3.7m'),
('v/bin/python', 'v/bin/pypy', 'pypy'),
),
)
diff --git a/tests/languages/r_test.py b/tests/languages/r_test.py
index 66aa7b3..5bc63b2 100644
--- a/tests/languages/r_test.py
+++ b/tests/languages/r_test.py
@@ -1,7 +1,10 @@
+from __future__ import annotations
+
import os.path
import pytest
+from pre_commit import envcontext
from pre_commit.languages import r
from testing.fixtures import make_config_from_repo
from testing.fixtures import make_repo
@@ -127,3 +130,14 @@ def test_r_parsing_file_local(tempdir_factory, store):
config=config,
expect_path_prefix=False,
)
+
+
+def test_rscript_exec_relative_to_r_home():
+ expected = os.path.join('r_home_dir', 'bin', 'Rscript')
+ with envcontext.envcontext((('R_HOME', 'r_home_dir'),)):
+ assert r._rscript_exec() == expected
+
+
+def test_path_rscript_exec_no_r_home_set():
+ with envcontext.envcontext((('R_HOME', envcontext.UNSET),)):
+ assert r._rscript_exec() == 'Rscript'
diff --git a/tests/languages/ruby_test.py b/tests/languages/ruby_test.py
index 7dff046..dc55456 100644
--- a/tests/languages/ruby_test.py
+++ b/tests/languages/ruby_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import os.path
import tarfile
from unittest import mock