Exemple #1
0
def test_iterwrite_io():
    collection = _get_collection()
    f = io.BytesIO()
    with biocxml.iterwrite(f) as writer:
        writer.write_collection_info(collection)
        for document in collection.documents:
            writer.write_document(document)

    collection = biocxml.loads(f.getvalue().decode('utf-8'))
    assert_everything(collection)
Exemple #2
0
def test_loads():
    with open(file, encoding='utf8') as fp:
        s = fp.read()
    collection = biocxml.loads(s)
    assert_everything(collection)
Exemple #3
0
def test_file_type():
    with pytest.raises(ValueError):
        biocxml.load(open(file, encoding='utf8'), None)

    with pytest.raises(ValueError):
        biocxml.loads('', None)
Exemple #4
0
def test_dumps():
    collection = _get_collection()
    s = biocxml.dumps(collection)
    collection = biocxml.loads(s)
    assert_everything(collection)
Exemple #5
0
def test_dumps():
    collection = _get_collection()
    s = biocxml.dumps(collection, version=bioc.BioCVersion.V2)
    collection = biocxml.loads(s, version=bioc.BioCVersion.V2)
    assert_everything(collection)