Skip to content
Snippets Groups Projects
Commit 318321a2 authored by Amandine  PERRIN's avatar Amandine PERRIN
Browse files

get report of unit tests coverage

parent d78b8866
No related branches found
No related tags found
No related merge requests found
Pipeline #62549 failed
...@@ -143,6 +143,8 @@ coverage: ...@@ -143,6 +143,8 @@ coverage:
- pip3 install -r requirements-dev.txt - pip3 install -r requirements-dev.txt
script: script:
- pwd - pwd
- mv .coverage.unit .coverage
- coverage report
- coverage combine .coverage.unit .coverage.functional - coverage combine .coverage.unit .coverage.functional
- coverage report -i - coverage report -i
- coverage html -i - coverage html -i
......
...@@ -200,6 +200,8 @@ class Conf_all_parser(configparser.ConfigParser): ...@@ -200,6 +200,8 @@ class Conf_all_parser(configparser.ConfigParser):
path to configuration file path to configuration file
readsec : list readsec : list
list of sections of the config file to read list of sections of the config file to read
clean_str : boolean
by default, remove " surrounding strings. If no need to do it, set this parameter to False
Attributes Attributes
---------- ----------
...@@ -209,7 +211,7 @@ class Conf_all_parser(configparser.ConfigParser): ...@@ -209,7 +211,7 @@ class Conf_all_parser(configparser.ConfigParser):
{section1: {param: value}, {section2: {param:value}}} {section1: {param: value}, {section2: {param:value}}}
""" """
def __init__(self, conffile, readsec=[]): def __init__(self, conffile, readsec=[], clean_str=True):
super().__init__() super().__init__()
# If there is a config file specified, but it does not exist -> exit with error message # If there is a config file specified, but it does not exist -> exit with error message
if conffile != "" and not os.path.isfile(conffile): if conffile != "" and not os.path.isfile(conffile):
...@@ -229,7 +231,8 @@ class Conf_all_parser(configparser.ConfigParser): ...@@ -229,7 +231,8 @@ class Conf_all_parser(configparser.ConfigParser):
# If not, create empty section, and associate with empty dict # If not, create empty section, and associate with empty dict
if sec in dict(self): if sec in dict(self):
self.sec_dicts[sec] = dict(self[sec]) self.sec_dicts[sec] = dict(self[sec])
self.clean_strings(sec) if clean_str:
self.clean_strings(sec)
else: else:
self.sec_dicts[sec] = {} self.sec_dicts[sec] = {}
self.add_section(sec) self.add_section(sec)
......
...@@ -271,6 +271,22 @@ def test_conf_parser_init(): ...@@ -271,6 +271,22 @@ def test_conf_parser_init():
"sec4": {}} # But sec4 dict is empty (no param given in configfile) "sec4": {}} # But sec4 dict is empty (no param given in configfile)
def test_conf_parser_clean_str(capsys):
"""
Check that surounding "" are removed
"""
cfg_file = os.path.join("test", "data", "utils", "configfile-str.ini")
c = autils.Conf_all_parser(cfg_file, ["sec2", "sec_bool"])
assert c.get_section_dict("sec2") == {"param2": "", "myval": "parameter",
'param3': "myparameter",
"param1": "3"}
assert c.get_section_dict("sec_bool") == {"bool num_false": "0", "bool_num_true": "1",
"bool_f": "off", "bool_t": "ON", "bool_n": "no",
"bool_y": "YES",
"bool_false": "FalSe", "bool_true": "tRUE",
"param1": "3", "param2": "10"}
def test_conf_parser_get_section(capsys): def test_conf_parser_get_section(capsys):
""" """
Test get dict of values for a given section Test get dict of values for a given section
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment