pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pre-commit/pre-commit/commit/d23990cc8b3b6040c0e5a7455ab7104cd60a5df4

css" /> use run_language for repository_test · pre-commit/pre-commit@d23990c · GitHub
Skip to content

Commit d23990c

Browse files
committed
use run_language for repository_test
1 parent 4f6ba18 commit d23990c

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

testing/language_helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def run_language(
1616
version: str | None = None,
1717
deps: Sequence[str] = (),
1818
is_local: bool = False,
19+
require_serial: bool = True,
20+
color: bool = False,
1921
) -> tuple[int, bytes]:
2022
prefix = Prefix(str(path))
2123
version = version or language.get_default_version()
@@ -31,8 +33,8 @@ def run_language(
3133
args,
3234
file_args,
3335
is_local=is_local,
34-
require_serial=True,
35-
color=False,
36+
require_serial=require_serial,
37+
color=color,
3638
)
3739
out = out.replace(b'\r\n', b'\n')
3840
return ret, out

tests/repository_test.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,24 @@
2525
from testing.fixtures import make_config_from_repo
2626
from testing.fixtures import make_repo
2727
from testing.fixtures import modify_manifest
28+
from testing.language_helpers import run_language
2829
from testing.util import cwd
2930
from testing.util import get_resource_path
3031

3132

32-
def _norm_out(b):
33-
return b.replace(b'\r\n', b'\n')
34-
35-
3633
def _hook_run(hook, filenames, color):
37-
with languages[hook.language].in_env(hook.prefix, hook.language_version):
38-
return languages[hook.language].run_hook(
39-
hook.prefix,
40-
hook.entry,
41-
hook.args,
42-
filenames,
43-
is_local=hook.src == 'local',
44-
require_serial=hook.require_serial,
45-
color=color,
46-
)
34+
return run_language(
35+
path=hook.prefix.prefix_dir,
36+
language=languages[hook.language],
37+
exe=hook.entry,
38+
args=hook.args,
39+
file_args=filenames,
40+
version=hook.language_version,
41+
deps=hook.additional_dependencies,
42+
is_local=hook.src == 'local',
43+
require_serial=hook.require_serial,
44+
color=color,
45+
)
4746

4847

4948
def _get_hook_no_install(repo_config, store, hook_id):
@@ -77,7 +76,7 @@ def _test_hook_repo(
7776
hook = _get_hook(config, store, hook_id)
7877
ret, out = _hook_run(hook, args, color=color)
7978
assert ret == expected_return_code
80-
assert _norm_out(out) == expected
79+
assert out == expected
8180

8281

8382
def test_python_hook(tempdir_factory, store):
@@ -425,7 +424,7 @@ def test_local_python_repo(store, local_python_config):
425424
assert hook.language_version != C.DEFAULT
426425
ret, out = _hook_run(hook, ('filename',), color=False)
427426
assert ret == 0
428-
assert _norm_out(out) == b"['filename']\nHello World\n"
427+
assert out == b"['filename']\nHello World\n"
429428

430429

431430
def test_default_language_version(store, local_python_config):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy