File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
main/python/opengrok_tools/utils Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,9 @@ def read_config(logger, inputfile):
62
62
# Not a valid YAML file.
63
63
logger .debug ("got exception {}" .format (sys .exc_info ()[0 ]))
64
64
else :
65
+ if cfg is None :
66
+ cfg = {}
67
+
65
68
return cfg
66
69
except IOError as e :
67
70
logger .error ("cannot open '{}': {}" .format (inputfile , e .strerror ))
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ #
4
+ # CDDL HEADER START
5
+ #
6
+ # The contents of this file are subject to the terms of the
7
+ # Common Development and Distribution License (the "License").
8
+ # You may not use this file except in compliance with the License.
9
+ #
10
+ # See LICENSE.txt included in this distribution for the specific
11
+ # language governing permissions and limitations under the License.
12
+ #
13
+ # When distributing Covered Code, include this CDDL HEADER in each
14
+ # file and include the License file at LICENSE.txt.
15
+ # If applicable, add the following below this CDDL HEADER, with the
16
+ # fields enclosed by brackets "[]" replaced with your own identifying
17
+ # information: Portions Copyright [yyyy] [name of copyright owner]
18
+ #
19
+ # CDDL HEADER END
20
+ #
21
+
22
+ #
23
+ # Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
24
+ #
25
+ import os
26
+ import tempfile
27
+ from mockito import mock
28
+ import logging
29
+
30
+ from opengrok_tools .utils .readconfig import read_config
31
+
32
+
33
+ def test_read_config_empty_yaml ():
34
+ tmpf = tempfile .NamedTemporaryFile (mode = 'w+t' , delete = False )
35
+ tmpf .file .write ('#foo\n ' )
36
+ tmpf .close ()
37
+ res = read_config (mock (spec = logging .Logger ), tmpf .name )
38
+ os .remove (tmpf .name )
39
+ assert res is not None
40
+ assert type (res ) == dict
41
+ assert len (res ) == 0
You can’t perform that action at this time.
0 commit comments