mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Simplify docker user fallback implementation and test
This commit is contained in:
parent
a21a4f46c7
commit
d4a9ff4d1f
2 changed files with 11 additions and 23 deletions
|
|
@ -15,15 +15,12 @@ def test_docker_is_running_process_error():
|
|||
assert docker.docker_is_running() is False
|
||||
|
||||
|
||||
def test_docker_fallback_uid():
|
||||
def test_docker_fallback_user():
|
||||
def invalid_attribute():
|
||||
raise AttributeError
|
||||
with mock.patch('os.getuid', invalid_attribute, create=True):
|
||||
assert docker.getuid() == docker.FALLBACK_UID
|
||||
|
||||
|
||||
def test_docker_fallback_gid():
|
||||
def invalid_attribute():
|
||||
raise AttributeError
|
||||
with mock.patch('os.getgid', invalid_attribute, create=True):
|
||||
assert docker.getgid() == docker.FALLBACK_GID
|
||||
with mock.patch.multiple(
|
||||
'os', create=True,
|
||||
getuid=invalid_attribute,
|
||||
getgid=invalid_attribute,
|
||||
):
|
||||
assert docker.get_docker_user() == '1000:1000'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue