How to use the javaproperties.Properties 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_propclass.py View on Github external
def test_propclass_repr_noinit():
    p = Properties()
    assert repr(p) \
        == 'javaproperties.propclass.Properties({!r}, defaults={!r})'\
            .format({}, None)
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_loadFromXML():
    p = Properties()
    p.loadFromXML(StringIO(XML_INPUT))
    assert len(p) == 4
    assert bool(p)
    assert dict(p) == {
        "foo": "second definition",
        "bar": "only definition",
        "key": "value",
        "zebra": "apple",
    }
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_empty_setitem(fixed_timestamp):
    p = Properties()
    p["key"] = "value"
    assert len(p) == 1
    assert bool(p)
    assert dict(p) == {"key": "value"}
    s = StringIO()
    p.store(s)
    assert s.getvalue() == '#' + fixed_timestamp + '\nkey=value\n'
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_delitem():
    p = Properties()
    p.load(StringIO(INPUT))
    del p["key"]
    assert len(p) == 3
    assert bool(p)
    assert dict(p) == {
        "foo": "second definition",
        "bar": "only definition",
        "zebra": "apple",
    }
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_del_nonstring_key():
    p = Properties({"key": "value", "apple": "zebra", "foo": "bar"})
    with pytest.raises(TypeError) as excinfo:
        del p[42]
    assert str(excinfo.value) == \
        'Keys & values of Properties instances must be strings'
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_empty(fixed_timestamp):
    p = Properties()
    assert len(p) == 0
    assert not bool(p)
    assert dict(p) == {}
    s = StringIO()
    p.store(s)
    assert s.getvalue() == '#' + fixed_timestamp + '\n'
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_eq_repeated_keys():
    p = Properties()
    p.load(StringIO('key = value\nkey: other value\n'))
    p2 = Properties()
    p2.load(StringIO('key: whatever\nkey other value'))
    assert p == p2
    assert dict(p) == dict(p2) == {"key": "other value"}
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_from_pairs_list():
    p = Properties([("key", "value"), ("apple", "zebra")])
    assert len(p) == 2
    assert bool(p)
    assert dict(p) == {"apple": "zebra", "key": "value"}
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_eq_different_comments():
    p = Properties()
    p.load(StringIO('#This is a comment.\nkey=value\n'))
    p2 = Properties()
    p2.load(StringIO('#This is also a comment.\nkey=value\n'))
    assert p == p2
    assert dict(p) == dict(p2)
github jwodder / javaproperties / test / test_propclass.py View on Github external
def test_propclass_defaults_eq_dict():
    defs = Properties({"key": "lock", "horse": "orange"})
    p = Properties({"Foo": "BAR"}, defaults=defs)
    assert p == {"Foo": "BAR"}
    assert {"Foo": "BAR"} == p
    assert p != {"Foo": "bar"}
    assert {"Foo": "bar"} != p