Esempio n. 1
0
def test_read():
    ini = INI('test.ini')
    assert ini.read('section0', 'integer') == 39
    assert np.isclose(ini.read('section1', 'float'), np.e)
    assert ini.read('section0', 'string') == 'hello world, this is an ini file'
    assert ini.read('section1', 'list') == ['Linux', 'rocks']
    #assert ini.read('section1', 'tuple') == ('Linux', 'rocks')
    assert ini.read('section0', 'none') is None
    assert ini.read('section1', 'true') is True
    assert ini.read('section1', 'false') is False
Esempio n. 2
0
def test_read():
    ini = INI("test.ini")
    assert ini.read("section0", "integer") == 39
    assert np.isclose(ini.read("section1", "float"), np.e)
    assert ini.read("section0", "string") == "hello world, this is an ini file"
    assert ini.read("section1", "list") == ["Linux", "rocks"]
    # assert ini.read('section1', 'tuple') == ('Linux', 'rocks')
    assert ini.read("section0", "none") is None
    assert ini.read("section1", "true") is True
    assert ini.read("section1", "false") is False
Esempio n. 3
0
def test_create():
    ini = INI("test.ini")
    ini.add_section("section0")
    ini.add_section("section1")
    ini.write("section0", "integer", 39)
    ini.write("section1", "float", np.e)
    ini.write("section0", "string", "hello world, this is an ini file")
    ini.write("section1", "list", ["Linux", "rocks"])
    ini.write("section1", "tuple", ("Linux", "rocks"))
    ini.write("section0", "none", None)
    ini.write("section1", "true", True)
    ini.write("section1", "false", False)
    ini.write("section0", "ndarray", np.linspace(0, 10, 21))
Esempio n. 4
0
def test_create():
    ini = INI('test.ini')
    ini.add_section('section0')
    ini.add_section('section1')
    ini.write('section0', 'integer', 39)
    ini.write('section1', 'float', np.e)
    ini.write('section0', 'string', 'hello world, this is an ini file')
    ini.write('section1', 'list', ['Linux', 'rocks'])
    ini.write('section1', 'tuple', ('Linux', 'rocks'))
    ini.write('section0', 'none', None)
    ini.write('section1', 'true', True)
    ini.write('section1', 'false', False)
    ini.write('section0', 'ndarray', np.linspace(0, 10, 21))
Esempio n. 5
0
def test_clear():
    ini = INI("test.ini")
    ini.clear()
    assert ini.sections == []
    os.remove("test.ini")
Esempio n. 6
0
def test_sections():
    ini = INI("test.ini")
    assert ini.sections == ["section0", "section1"]
Esempio n. 7
0
def test_get_options():
    ini = INI("test.ini")
    assert ini.get_options("section0") == [
        "integer", "string", "none", "ndarray"
    ]
Esempio n. 8
0
def test_dictionary():
    ini = INI("test.ini")
    dict_ = ini.dictionary
    assert isinstance(dict_, dict)
    assert dict_["section0"]["integer"] == "39"
Esempio n. 9
0
def test_has_section():
    ini = INI("test.ini")
    assert ini.has_section("section0")
    assert not ini.has_section("section9")
Esempio n. 10
0
def test_has_option():
    ini = INI("test.ini")
    assert ini.has_option("section0", "integer")
    assert not ini.has_option("section0", "nooooooooooooo")
Esempio n. 11
0
def test_sections():
    ini = INI('test.ini')
    assert ini.sections == ['section0', 'section1']
Esempio n. 12
0
def test_get_options():
    ini = INI('test.ini')
    assert ini.get_options('section0') == ['integer', 'string', 'none', 'ndarray']
Esempio n. 13
0
def test_dictionary():
    ini = INI('test.ini')
    dict_ = ini.dictionary
    assert isinstance(dict_, dict)
    assert dict_['section0']['integer'] == '39'
Esempio n. 14
0
def test_has_section():
    ini = INI('test.ini')
    assert ini.has_section('section0')
    assert not ini.has_section('section9')
Esempio n. 15
0
def test_has_option():
    ini = INI('test.ini')
    assert ini.has_option('section0', 'integer')
    assert not ini.has_option('section0', 'nooooooooooooo')