mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-27 02:20:48 -05:00
Simplify docker user fallback implementation and test
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user