File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,10 @@ Configuration
14
14
Files
15
15
-----
16
16
17
- ``gitlab `` looks up 2 configuration files by default:
17
+ ``gitlab `` looks up 3 configuration files by default:
18
+
19
+ ``PYTHON_GITLAB_CFG `` environment variable
20
+ An environment variable that contains the path to a configuration file
18
21
19
22
``/etc/python-gitlab.cfg ``
20
23
System-wide configuration file
Original file line number Diff line number Diff line change 18
18
import os
19
19
import configparser
20
20
21
- _DEFAULT_FILES = ["/etc/python-gitlab.cfg" , os .path .expanduser ("~/.python-gitlab.cfg" )]
21
+
22
+ def _env_config ():
23
+ if "PYTHON_GITLAB_CFG" in os .environ :
24
+ return [os .environ ["PYTHON_GITLAB_CFG" ]]
25
+ return []
26
+
27
+
28
+ _DEFAULT_FILES = _env_config () + [
29
+ "/etc/python-gitlab.cfg" ,
30
+ os .path .expanduser ("~/.python-gitlab.cfg" ),
31
+ ]
22
32
23
33
24
34
class ConfigError (Exception ):
Original file line number Diff line number Diff line change 15
15
# You should have received a copy of the GNU Lesser General Public License
16
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
18
+ import os
18
19
import unittest
19
20
20
21
import mock
72
73
"""
73
74
74
75
76
+ class TestEnvConfig (unittest .TestCase ):
77
+ def test_env_present (self ):
78
+ with mock .patch .dict (os .environ , {"PYTHON_GITLAB_CFG" : "/some/path" }):
79
+ self .assertEqual (["/some/path" ], config ._env_config ())
80
+
81
+ def test_env_missing (self ):
82
+ with mock .patch .dict (os .environ , {}, clear = True ):
83
+ self .assertEqual ([], config ._env_config ())
84
+
85
+
75
86
class TestConfigParser (unittest .TestCase ):
76
87
@mock .patch ("os.path.exists" )
77
88
def test_missing_config (self , path_exists ):
You can’t perform that action at this time.
0 commit comments