Skip to content

Commit

Permalink
Open ALTO files as binary
Browse files Browse the repository at this point in the history
  • Loading branch information
wrznr committed May 12, 2020
1 parent 5f9b462 commit c646567
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/test_alto.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,41 @@ def test_reading_local_file(datadir):
'''
Test reading a local alto file
'''
f = open(datadir.join('test_alto.xml'))
alto = Alto.read(f)
with open(datadir.join('test_alto.xml'), 'rb') as f:
alto = Alto.read(f)
assert(alto.tree is not None)

def test_loading_local_file(datadir):
'''
Test loading a local alto file
'''
f = open(datadir.join('test_alto.xml'))
alto = Alto.fromfile(f)
with open(datadir.join('test_alto.xml'), 'rb') as f:
alto = Alto.read(f)
assert(alto.tree is not None)

def test_text_block_extraction(datadir):
'''
Test the extraction of text blocks
'''
f = open(datadir.join('test_alto.xml'))
alto = Alto.fromfile(f)
with open(datadir.join('test_alto.xml'), 'rb') as f:
alto = Alto.read(f)
assert(len(list(alto.get_text_blocks())) == 1)

def test_text_line_extraction(datadir):
'''
Test the extraction of text lines
'''
f = open(datadir.join('test_alto.xml'))
alto = Alto.fromfile(f)
with open(datadir.join('test_alto.xml'), 'rb') as f:
alto = Alto.read(f)
text_block = list(alto.get_text_blocks())[0]
assert(len(list(alto.get_lines_in_text_block(text_block))) == 26)

def test_text_line_text_extraction(datadir):
'''
Test the extraction of text from text lines
'''
f = open(datadir.join('test_alto.xml'))
alto = Alto.fromfile(f)
with open(datadir.join('test_alto.xml'), 'rb') as f:
alto = Alto.read(f)
text_block = list(alto.get_text_blocks())[0]
text_line = list(alto.get_lines_in_text_block(text_block))[0]
assert(alto.get_text_in_line(text_line) == "Vorbericht.")

0 comments on commit c646567

Please sign in to comment.