How to use the javaproperties.PropertiesFile function in javaproperties

To help you get started, we’ve selected a few javaproperties examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_empty():
    pf = PropertiesFile()
    pf._check()
    assert len(pf) == 0
    assert not bool(pf)
    assert dict(pf) == {}
    assert list(pf) == []
    assert list(reversed(pf)) == []
    assert pf.dumps() == ''
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_eq_empty():
    pf = PropertiesFile()
    pf2 = PropertiesFile()
    assert pf is not pf2
    assert pf == pf2
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_eq_nonempty():
    pf = PropertiesFile({"Foo": "bar"})
    pf2 = PropertiesFile({"Foo": "bar"})
    assert pf is not pf2
    assert pf == pf2
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_get_nonstring_key():
    pf = PropertiesFile({"key": "value", "apple": "zebra", "foo": "bar"})
    with pytest.raises(TypeError) as excinfo:
        pf[42]
    assert str(excinfo.value) == \
        'Keys & values of PropertiesFile instances must be strings'
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_set_nonstring_value():
    pf = PropertiesFile({"key": "value", "apple": "zebra", "foo": "bar"})
    with pytest.raises(TypeError) as excinfo:
        pf['forty-two'] = 42
    assert str(excinfo.value) == \
        'Keys & values of PropertiesFile instances must be strings'
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_neq():
    assert PropertiesFile({"Foo": "bar"}) != PropertiesFile({"Foo": "BAR"})
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_from_ordereddict():
    pf = PropertiesFile(OrderedDict([('key', 'value'), ('apple', 'zebra')]))
    pf._check()
    assert len(pf) == 2
    assert bool(pf)
    assert dict(pf) == {"apple": "zebra", "key": "value"}
    assert list(pf) == ["key", "apple"]
    assert list(reversed(pf)) == ["apple", "key"]
    assert pf.dumps() == 'key=value\napple=zebra\n'
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_from_ordereddict_and_kwarg():
    pf = PropertiesFile(OrderedDict([('key', 'value'), ('apple', 'zebra')]),
                        key='lock')
    pf._check()
    assert len(pf) == 2
    assert bool(pf)
    assert dict(pf) == {"apple": "zebra", "key": "lock"}
    assert list(pf) == ["key", "apple"]
    assert list(reversed(pf)) == ["apple", "key"]
    assert pf.dumps() == 'key=lock\napple=zebra\n'
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_del_nonstring_key():
    pf = PropertiesFile({"key": "value", "apple": "zebra", "foo": "bar"})
    with pytest.raises(TypeError) as excinfo:
        del pf[42]
    assert str(excinfo.value) == \
        'Keys & values of PropertiesFile instances must be strings'
github jwodder / javaproperties / test / test_propfile.py View on Github external
def test_propfile_eq_dict():
    pf = PropertiesFile({"Foo": "BAR"})
    assert pf == {"Foo": "BAR"}
    assert {"Foo": "BAR"} == pf
    assert pf != {"Foo": "bar"}
    assert {"Foo": "bar"} != pf