def test_get_config(tmp_path): ''' Test get_config ''' ini_file = ''' [section1] key1 = value1 key2 = value2 [section2] key3 = value3 ''' ini_path = tmp_path / 'test_get_config.ini' ini_path.write(ini_file) print("section1,key1:", config_get("section1", "key1", ini_file=ini_path.name)) assert config_get("section1", "key1", ini_file=ini_path.name) == "value1" assert config_get("section1", "key2", ini_file=ini_path.name) == "value2" assert config_get("section2", "key3", ini_file=ini_path.name) == "value3" assert config_get("section3", "key4", default="Hallo", ini_file=ini_path.name) == "Hallo" assert config_get("section2", "key4", default="Bubu", ini_file=ini_path.name) == "Bubu"
def test_get_config(self): ''' Test get_config ''' ini_file = ''' [section1] key1 = value1 key2 = value2 [section2] key3 = value3 ''' t = tempfile.NamedTemporaryFile(delete=False) t.write(ini_file) t.close() print "section1,key1:", config_get("section1", "key1", ini_file=t.name) assert config_get("section1", "key1", ini_file=t.name) == "value1" assert config_get("section1", "key2", ini_file=t.name) == "value2" assert config_get("section2", "key3", ini_file=t.name) == "value3" assert config_get("section3", "key4", default="Hallo", ini_file=t.name) == "Hallo" assert config_get("section2", "key4", default="Bubu", ini_file=t.name) == "Bubu"