Ejemplo n.º 1
0
def test_ObjDict_load():
    """Test :func:`~utilipy.utils.collections.ObjDict.load`."""
    od = ObjDict(name="name", a=1, b=None, c="c")

    with tempfile.TemporaryDirectory() as tempdir:
        tempath = os.path.join(tempdir, "temp.pkl")
        od.dump(
            tempath,
            protocol=None,
            fopt="b",
            fix_imports=True,
        )

        new_od = ObjDict.load(
            tempath,
            fopt="b",
            fix_imports=True,
            encoding="ASCII",
            errors="strict",
        )

    # /with

    # test equality between new and old
    assert new_od.name == od.name
    assert new_od.items() == od.items()
Ejemplo n.º 2
0
def test_ObjDict_dump():
    """Test :func:`~utilipy.utils.collections.ObjDict.dump`."""
    od = ObjDict(name="name", a=1, b=None, c="c")

    with tempfile.TemporaryDirectory() as tempdir:
        tempath = os.path.join(tempdir, "temp.pkl")
        od.dump(
            tempath,
            protocol=None,
            fopt="b",
            fix_imports=True,
        )