File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515ENVIRONMENT_DIR = 'docker'
1616PRE_COMMIT_LABEL = 'PRE_COMMIT'
17- FALLBACK_UID = 1000
18- FALLBACK_GID = 1000
1917get_default_version = helpers .basic_get_default_version
2018healthy = helpers .basic_healthy
2119
@@ -75,25 +73,18 @@ def install_environment(
7573 os .mkdir (directory )
7674
7775
78- def getuid (): # pragma: windows no cover
76+ def get_docker_user (): # pragma: windows no cover
7977 try :
80- return os .getuid ()
78+ return '{}:{}' . format ( os .getuid (), os . getgid () )
8179 except AttributeError :
82- return FALLBACK_UID
83-
84-
85- def getgid (): # pragma: windows no cover
86- try :
87- return os .getgid ()
88- except AttributeError :
89- return FALLBACK_GID
80+ return '1000:1000'
9081
9182
9283def docker_cmd (): # pragma: windows no cover
9384 return (
9485 'docker' , 'run' ,
9586 '--rm' ,
96- '-u' , '{}:{}' . format ( getuid (), getgid () ),
87+ '-u' , get_docker_user ( ),
9788 # https://docs.docker.com/engine/reference/commandline/run/#mount-volumes-from-container-volumes-from
9889 # The `Z` option tells Docker to label the content with a private
9990 # unshared label. Only the current container can use a private volume.
Original file line number Diff line number Diff line change @@ -15,15 +15,12 @@ def test_docker_is_running_process_error():
1515 assert docker .docker_is_running () is False
1616
1717
18- def test_docker_fallback_uid ():
18+ def test_docker_fallback_user ():
1919 def invalid_attribute ():
2020 raise AttributeError
21- with mock .patch ('os.getuid' , invalid_attribute , create = True ):
22- assert docker .getuid () == docker .FALLBACK_UID
23-
24-
25- def test_docker_fallback_gid ():
26- def invalid_attribute ():
27- raise AttributeError
28- with mock .patch ('os.getgid' , invalid_attribute , create = True ):
29- assert docker .getgid () == docker .FALLBACK_GID
21+ with mock .patch .multiple (
22+ 'os' , create = True ,
23+ getuid = invalid_attribute ,
24+ getgid = invalid_attribute ,
25+ ):
26+ assert docker .get_docker_user () == '1000:1000'
You can’t perform that action at this time.
0 commit comments