Skip to content

Commit

Permalink
Fix text carrier-over between pages. Fix tests.
Browse files Browse the repository at this point in the history
1. Fixed tests by including newlines from extracted documents
2. Added test to illustrate merge bug from commit
43614f2 in which uncleared buffer
carries text between pages
3. Added clearing of buffer that also addresses issue #21 in the prior
codebase
  • Loading branch information
Joel Steres committed Nov 5, 2015
1 parent 4bfa21f commit d91b5a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/slate/classes.py
Expand Up @@ -41,6 +41,7 @@ def process_page(self, page):
else:
ctm = (1,0,0,1, -x0,-y0)
self.device.outfp.seek(0)
self.device.outfp.truncate(0)
self.device.begin_page(page, ctm)
self.render_contents(page.resources, page.contents, ctm=ctm)
self.device.end_page(page)
Expand Down
7 changes: 5 additions & 2 deletions src/slate/unittests.py
Expand Up @@ -10,7 +10,10 @@ def setUp(self):
self.passwd = PDF(f, 'a')

def test_basic(self):
assert self.doc[0] == 'This is a test.\x0c'
assert self.doc[0] == 'This is a test.\n\n\x0c'

def test_no_text_carry_over(self):
assert self.doc[1] == '\x0c'

def test_metadata_extraction(self):
assert self.doc.metadata
Expand All @@ -22,7 +25,7 @@ def test_text_method_unclean(self):
assert '\x0c' in self.doc.text(clean=0)

def test_password(self):
assert self.passwd[0] == "Chamber of secrets.\x0c"
assert self.passwd[0] == "Chamber of secrets.\n\n\x0c"

if __name__ == '__main__':
unittest.main()

0 comments on commit d91b5a6

Please sign in to comment.