File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,12 @@ def _parse_config(self) -> None:
137137 _config = configparser .ConfigParser ()
138138 _config .read (self ._files )
139139
140+ if self .gitlab_id and not _config .has_section (self .gitlab_id ):
141+ raise GitlabDataError (
142+ f"A gitlab id was provided ({ self .gitlab_id } ) "
143+ "but no config section found"
144+ )
145+
140146 if self .gitlab_id is None :
141147 try :
142148 self .gitlab_id = _config .get ("global" , "default" )
Original file line number Diff line number Diff line change 2525import responses
2626
2727import gitlab
28- from gitlab .config import GitlabConfigMissingError
28+ from gitlab .config import GitlabConfigMissingError , GitlabDataError
2929from tests .unit import helpers
3030
3131localhost = "http://localhost"
@@ -305,6 +305,11 @@ def test_gitlab_from_config_without_files_raises():
305305 gitlab .Gitlab .from_config ("non-existing" )
306306
307307
308+ def test_gitlab_from_config_with_wrong_gitlab_id_raises (default_config ):
309+ with pytest .raises (GitlabDataError , match = "non-existing" ):
310+ gitlab .Gitlab .from_config ("non-existing" , [default_config ])
311+
312+
308313def test_gitlab_subclass_from_config (default_config ):
309314 class MyGitlab (gitlab .Gitlab ):
310315 pass
You can’t perform that action at this time.
0 commit comments