Skip to content

Commit

Permalink
Chipping at test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mgedmin committed Dec 3, 2014
1 parent afaf6bc commit d8d2157
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests.py
Expand Up @@ -42,6 +42,10 @@ def test_split(self):
bits = chunk.split(canvas, 100, 50, 200)
self.assertEqual(bits, [chunk])

def test_repr(self):
chunk = mgp2pdf.SimpleChunk()
self.assertEqual(str(chunk), '<SimpleChunk>')


class TestImage(unittest.TestCase):

Expand All @@ -56,6 +60,19 @@ def test_drawOn_error_handling(self, mock_log, mock_ImageReader):
self.assertEqual((x, y), (60, 20))


class TestTextChunk(unittest.TestCase):

def test_split_when_it_cant(self):
canvas = mock.Mock()
canvas.stringWidth = lambda s, font, size: len(s) * 7
chunk = mgp2pdf.TextChunk("this-is-a-very-long, unsplittable, word",
"Arial", 6, 0, mgp2pdf.parse_color("black"))
bits = chunk.split(canvas, 1024, 768, 130)
self.assertEqual(len(bits), 2)
self.assertEqual(bits[0].text, "this-is-a-very-long,")
self.assertEqual(bits[1].text, "unsplittable, word")


def test_suite():
return unittest.TestSuite([
doctest.DocTestSuite('mgp2pdf'),
Expand Down

0 comments on commit d8d2157

Please sign in to comment.