mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +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 os
|
||||
from typing import Sequence
|
||||
|
|
@ -26,6 +27,7 @@ def docker_tag(prefix: Prefix) -> str: # pragma: win32 no cover
|
|||
return f'pre-commit-{md5sum}'
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=1)
|
||||
def docker_is_running() -> bool: # pragma: win32 no cover
|
||||
try:
|
||||
cmd_output_b('docker', 'ps')
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from pre_commit.util import CalledProcessError
|
|||
|
||||
|
||||
def test_docker_is_running_process_error():
|
||||
docker.docker_is_running.cache_clear()
|
||||
with mock.patch(
|
||||
'pre_commit.languages.docker.cmd_output_b',
|
||||
side_effect=CalledProcessError(1, (), 0, b'', None),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue