Ejemplo n.º 1
0
def test_failed_read():
    disp = dispatch.Dispatch()
    disp.register(text.TextAdaptor())

    # Attempt to read hdf5 using text adaptor
    hdf5_filename = "tests/data/hdf5_format_v1/training.scale=0.50,sigma=10.h5"
    x, err = disp.read_safely(hdf5_filename)

    # There should be an error
    assert err is not None
Ejemplo n.º 2
0
def test_text_adaptor(tmpdir):
    disp = dispatch.Dispatch()
    disp.register(text.TextAdaptor())

    filename = os.path.join(tmpdir, "textfile.txt")
    some_text = "some text to save in a file"

    disp.write(filename, some_text)

    read_text = disp.read(filename)

    assert some_text == read_text
Ejemplo n.º 3
0
def test_missing_file():
    disp = dispatch.Dispatch()
    disp.register(text.TextAdaptor())

    with pytest.raises(FileNotFoundError):
        disp.read("missing_file.txt")