aboutsummaryrefslogtreecommitdiffstats
path: root/mapreduce/tests/test_grobid2json.py
blob: 156200659546b7971d9b1aa60d1e26d55fb2566b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

import xml
import json
import pytest
from grobid2json import *


def test_small_xml():
    
    with open('tests/files/small.xml', 'r') as f:
        tei_xml = f.read()
    with open('tests/files/small.json', 'r') as f:
        json_form  = json.loads(f.read())

    assert teixml2json(tei_xml) == json_form

def test_invalid_xml():

    with pytest.raises(xml.etree.ElementTree.ParseError):
        teixml2json("this is not XML")
    with pytest.raises(xml.etree.ElementTree.ParseError):
        teixml2json("<xml></xml>")