mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
add lru_cache to docker_is_running
This commit is contained in:
parent
f1de792877
commit
b34b1a0ab3
2 changed files with 3 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import functools
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
from typing import Sequence
|
from typing import Sequence
|
||||||
|
|
@ -26,6 +27,7 @@ def docker_tag(prefix: Prefix) -> str: # pragma: win32 no cover
|
||||||
return f'pre-commit-{md5sum}'
|
return f'pre-commit-{md5sum}'
|
||||||
|
|
||||||
|
|
||||||
|
@functools.lru_cache(maxsize=1)
|
||||||
def docker_is_running() -> bool: # pragma: win32 no cover
|
def docker_is_running() -> bool: # pragma: win32 no cover
|
||||||
try:
|
try:
|
||||||
cmd_output_b('docker', 'ps')
|
cmd_output_b('docker', 'ps')
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ from pre_commit.util import CalledProcessError
|
||||||
|
|
||||||
|
|
||||||
def test_docker_is_running_process_error():
|
def test_docker_is_running_process_error():
|
||||||
|
docker.docker_is_running.cache_clear()
|
||||||
with mock.patch(
|
with mock.patch(
|
||||||
'pre_commit.languages.docker.cmd_output_b',
|
'pre_commit.languages.docker.cmd_output_b',
|
||||||
side_effect=CalledProcessError(1, (), 0, b'', None),
|
side_effect=CalledProcessError(1, (), 0, b'', None),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue