Skip to content
This repository
Browse code

Rationalized tests. Nosetests + coverage work as expected now.

  • Loading branch information...
commit 03221122d813b248d433f739fd1f70f3765f8a33 1 parent 44c5c11
Chris Glass authored
9 .coveragerc
... ... @@ -0,0 +1,9 @@
  1 +[run]
  2 +branch = True
  3 +source =
  4 + xhtml2pdf
  5 +omit =
  6 + /usr/share/*
  7 +
  8 +[report]
  9 +precision = 2
2  .gitignore
@@ -17,3 +17,5 @@ build/
17 17 dist/
18 18 testrender/output/
19 19 *.swp
  20 +.coverage
  21 +htmlcov/
5 tests/test_parser.py
... ... @@ -1,7 +1,6 @@
1 1 import unittest
2   -from sx.pisa3.pisa_parser import pisaParser
3   -from sx.pisa3.pisa_context import pisaContext
4   -import StringIO
  2 +from xhtml2pdf.parser import pisaParser
  3 +from xhtml2pdf.context import pisaContext
5 4
6 5 _data = """
7 6 <!doctype html>
193 tests/test_samples.py
... ... @@ -1,193 +0,0 @@
1   -import sys
2   -import glob
3   -import subprocess
4   -import tempfile
5   -import os
6   -import os.path
7   -
8   -__version__ = "0.1"
9   -
10   -class VisualObject:
11   -
12   - CONVERT = r"C:\Programme\ImageMagick-6.3.8-Q16\convert.exe"
13   - DIFF = r"C:\Programme\TortoiseSVN\bin\tortoiseidiff.exe"
14   - SUFFIX = ".png"
15   -
16   - # C:\Programme\gs\gs8.54\bin\gswin32.exe -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile=rl_hello-page%04d.png -sDEVICE=png256 -r144x144 -f test-font-and-styles.pdf
17   - #
18   -
19   - def __init__(self):
20   - self.files = []
21   - self.files4del = []
22   - self.folder4del = None
23   -
24   - def __del__(self):
25   - for file in self.files4del:
26   - os.remove(file)
27   - self.files4del = []
28   - if self.folder4del:
29   - os.rmdir(self.folder4del)
30   - self.folder4del = None
31   -
32   - def execute(self, *a):
33   - #print
34   - #print "EXECUTE", " ".join(a)
35   - #print
36   - # os.system(" ".join(a))
37   - r = subprocess.Popen(a, stdout=subprocess.PIPE).communicate()[0]
38   - # print r
39   - return r
40   -
41   - def showDiff(self, left, right):
42   - return self.execute(self.DIFF, "/fit", "/overlay", "/left:" + left, "/right:" + right)
43   -
44   - def convertFile(self, source, destination):
45   - self.execute(self.CONVERT, "-strip", source, destination)
46   -
47   - def getFiles(self, folder, pattern="*.*"):
48   - pattern = os.path.join(folder, pattern)
49   - self.files = [os.path.abspath(x) for x in glob.glob(pattern)]
50   - self.files.sort()
51   - # print "FILES", self.files
52   - return self.files
53   -
54   - def loadFile(self, file, folder=None, delete=True):
55   - if folder is None:
56   - folder = self.folder4del = tempfile.mkdtemp(prefix="visualdiff-tmp-")
57   - delete = True
58   - # print "FOLDER", folder, "DELETE", delete
59   - source = os.path.abspath(file)
60   - destination = os.path.join(folder, os.path.basename(file) + "-%04d" + self.SUFFIX)
61   - self.convertFile(source, destination)
62   - self.getFiles(folder, os.path.basename(file) + "-????" + self.SUFFIX)
63   - if delete:
64   - self.files4del = self.files
65   - return folder
66   -
67   - def compare(self, other, chunk=16*1024, show=True):
68   - if not self.files:
69   - return False, "No files"
70   - if len(self.files) <> len(other.files):
71   - return False, "Different number of files"
72   - for i in range(len(self.files)):
73   - left = self.files[i]
74   - right = other.files[i]
75   - a = open(left, "rb")
76   - b = open(right, "rb")
77   - diff = a.read() <> b.read()
78   - a.close()
79   - b.close()
80   - del a
81   - del b
82   - if diff:
83   - if show:
84   - self.showDiff(left, right)
85   - return False, "Difference in file %r" % left
86   - return True, ""
87   -
88   -'''
89   -def getoptions():
90   - from optparse import OptionParser
91   - usage = "usage: %prog [options] arg"
92   - description = """
93   - Visual Differences
94   - """.strip()
95   - version = __version__
96   - parser = OptionParser(
97   - usage,
98   - description=description,
99   - version=version,
100   - )
101   - #parser.add_option(
102   - # "-c", "--css",
103   - # help="Path to default CSS file",
104   - # dest="css",
105   - # )
106   - parser.add_option("-q", "--quiet",
107   - action="store_false", dest="verbose", default=True,
108   - help="don't print status messages to stdout")
109   - parser.set_defaults(
110   - # css=None,
111   - )
112   - (options, args) = parser.parse_args()
113   -
114   - #if not (0 < len(args) <= 2):
115   - # parser.error("incorrect number of arguments")
116   -
117   - return options, args
118   -
119   -def main_command():
120   -
121   - options, args = getoptions()
122   -
123   - print args
124   -
125   - a = VisualObject()
126   - b = VisualObject()
127   -
128   - a.loadFile("expected/test-loremipsum.pdf")
129   - b.files = a.files
130   -
131   - print a.compare(b)
132   -'''
133   -
134   -import unittest
135   -import sx.pisa3.pisa as pisa
136   -import shutil
137   -
138   -class TestCase(unittest.TestCase):
139   -
140   - def testSamples(self):
141   -
142   - # Enable logging
143   - pisa.showLogging()
144   -
145   - # Calculate paths
146   - here = os.path.abspath(os.path.join(__file__, os.pardir))
147   - folder = os.path.join(here, "tmp")
148   - left = os.path.join(folder, "left")
149   - right = os.path.join(folder, "right")
150   -
151   - # Cleanup old tests and create new structure
152   - if os.path.isdir(folder):
153   - shutil.rmtree(folder)
154   - os.makedirs(left)
155   - os.makedirs(right)
156   -
157   - for name in glob.glob(os.path.join(here, "samples", "*.html")):
158   - # print name
159   -
160   - # Create new PDF
161   - bname = os.path.basename(name)
162   - fname = os.path.join(right, bname[:-5] + ".pdf")
163   -
164   - dest = open(fname, "wb")
165   - pdf = pisa.pisaDocument(
166   - open(name, "rb"),
167   - dest,
168   - path = name)
169   - dest.close()
170   -
171   - self.assertTrue(not pdf.err, name)
172   -
173   - # New object
174   - r = VisualObject()
175   - r.loadFile(fname, right, delete=False)
176   -
177   - # Expected object
178   - l = VisualObject()
179   - l.loadFile(name[:-5] + ".pdf", left, delete=False)
180   -
181   - # Compare both and open Diff if differences
182   - result, msg = l.compare(r)
183   - self.assertTrue(result, name + ": " + msg)
184   -
185   -def buildTestSuite():
186   - return unittest.defaultTestLoader.loadTestsFromName(__name__)
187   -
188   -def main():
189   - buildTestSuite()
190   - unittest.main()
191   -
192   -if __name__ == "__main__":
193   - main()
122 tests/test_uri.py
... ... @@ -1,122 +0,0 @@
1   -import unittest
2   -from sx.pisa3.pisa_util import *
3   -
4   -_datauri = """data:image/png;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eq8PGtpTTAHVallQlWNmLIZN0Jwavg0nXb7ecXJHFcL9h
58   -6nRdSf/IT/eDTcgQd8C7tGLS8qjD/Od8lManTUyGX22zFJaMejlHyNmsYZbmQx9ypvVAKxilQdME
59   -mu3ZyGqwH6bUWCLuaTDWCuoBZ9p5jUI9fgYdlXpWt6tg6hpCuskdBt+26/ObCjT5TtjGYyhZswJ7
60   -8w8KFUDDGP5O12YoPsCevzMOGtrSoebJT6CogUjuYtvW+UcuDLB6VZ6Bzd83AJY83iggq9Fs4MDp
61   -w4+QR6n4xrwfduVKtbrZIyeBS6/FPmh17T78KeVhjG3CRswcWt7cnw5m0fg6Lf3VATvqw1PUjt3l
62   -GYCGj2TKE9Eeo54PRVgbfxwdVS3Y2UY1dJUgoaWJqDrdVGf5TsXJsZnHSsQWmtbQlZkgSjS1f6uF
63   -RIv/cvY8e7gdDvmpE7BHblrWL1r8JbOZrs0wZuFjHp8NDQWtFnsmEMD4P1oK8Sv7gdVGAAAAAElF
64   -TkSuQmCC"""
65   -
66   -class TestCase(unittest.TestCase):
67   -
68   - def testAbsouluteUri(self):
69   -
70   - # URL
71   - f = getFile("http://www.holtwick.it")
72   - c = f.getFile().read(1)
73   -
74   - self.assertEqual(len(c), 1)
75   - self.assertEqual(c, "<")
76   - self.assertEqual(f.mimetype, "text/html")
77   -
78   - # Path
79   - f = getFile("__init__.py")
80   - c = f.getFile().read(1)
81   -
82   - self.assertEqual(len(c), 1)
83   - self.assertEqual(c, "f")
84   - self.assertEqual(f.mimetype, "text/x-python")
85   -
86   - # Data URI
87   - f = getFile(_datauri)
88   - c = f.getFile().read(1)
89   -
90   - self.assertEqual(len(c), 1)
91   - self.assertEqual(c, '\x89')
92   - self.assertEqual(f.mimetype, "image/png")
93   -
94   - def testRelativeUri(self):
95   -
96   - # URL
97   - f = getFile("index", basepath="http://www.holtwick.it")
98   - c = f.getFile().read(1)
99   -
100   - self.assertEqual(len(c), 1)
101   - self.assertEqual(c, "<")
102   - self.assertEqual(f.mimetype, "text/html")
103   -
104   - # Path
105   - base = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir)
106   - f = getFile("tests/__init__.py", base)
107   - c = f.getFile().read(1)
108   -
109   - # print f.mimetype
110   - self.assertEqual(len(c), 1)
111   - self.assertEqual(c, "f")
112   - self.assertEqual(f.mimetype, "text/x-python")
113   -
114   -def buildTestSuite():
115   - return unittest.defaultTestLoader.loadTestsFromName(__name__)
116   -
117   -def main():
118   - buildTestSuite()
119   - unittest.main()
120   -
121   -if __name__ == "__main__":
122   - main()
132 tests/test_utils.py
... ... @@ -0,0 +1,132 @@
  1 +#-*- coding: utf-8 -*-
  2 +from reportlab.lib.colors import Color
  3 +from unittest import TestCase
  4 +from xhtml2pdf.util import getCoords, getColor, getSize
  5 +
  6 +class UtilsCoordTestCase(TestCase):
  7 +
  8 + def test_getCoords_simple(self):
  9 +
  10 + res = getCoords(1, 1, 10, 10, (10,10))
  11 + self.assertEqual(res, (1, -1, 10, 10))
  12 +
  13 + # A second time - it's memoized!
  14 + res = getCoords(1, 1, 10, 10, (10,10))
  15 + self.assertEqual(res, (1, -1, 10, 10))
  16 +
  17 + def test_getCoords_x_lt_0(self):
  18 + res = getCoords(-1, 1, 10, 10, (10,10))
  19 + self.assertEqual(res, (9, -1, 10, 10))
  20 +
  21 + def test_getCoords_y_lt_0(self):
  22 + res = getCoords(1, -1, 10, 10, (10,10))
  23 + self.assertEqual(res, (1, -9, 10, 10))
  24 +
  25 + def test_getCoords_w_and_h_none(self):
  26 + res = getCoords(1, 1, None, None, (10,10))
  27 + self.assertEqual(res, (1, 9))
  28 +
  29 + def test_getCoords_w_lt_0(self):
  30 + res = getCoords(1, 1, -1, 10, (10,10))
  31 + self.assertEqual(res, (1, -1, 8, 10))
  32 +
  33 + def test_getCoords_h_lt_0(self):
  34 + res = getCoords(1, 1, 10, -1, (10,10))
  35 + self.assertEqual(res, (1, 1, 10, 8))
  36 +
  37 +class UtilsColorTestCase(TestCase):
  38 +
  39 + def test_get_color_simple(self):
  40 + res = getColor('red')
  41 + self.assertEqual(res, Color(1,0,0,1))
  42 +
  43 + # Testing it being memoized properly
  44 + res = getColor('red')
  45 + self.assertEqual(res, Color(1,0,0,1))
  46 +
  47 + def test_get_color_from_color(self):
  48 + # Noop if argument is already a color
  49 + res = getColor(Color(1,0,0,1))
  50 + self.assertEqual(res, Color(1,0,0,1))
  51 +
  52 + def test_get_transparent_color(self):
  53 + res = getColor('transparent', default='TOKEN')
  54 + self.assertEqual(res, 'TOKEN')
  55 +
  56 + res = getColor('none', default='TOKEN')
  57 + self.assertEqual(res, 'TOKEN')
  58 +
  59 + def test_get_color_for_none(self):
  60 + res = getColor(None, default='TOKEN')
  61 + self.assertEqual(res, 'TOKEN')
  62 +
  63 + def test_get_color_for_RGB(self):
  64 + res = getColor('#FF0000')
  65 + self.assertEqual(res, Color(1,0,0,1))
  66 +
  67 + def test_get_color_for_RGB_with_len_4(self):
  68 + res = getColor('#F00')
  69 + self.assertEqual(res, Color(1,0,0,1))
  70 +
  71 + def test_get_color_for_CSS_RGB_function(self):
  72 + # It's regexp based, let's try common cases.
  73 + res = getColor('rgb(255,0,0)')
  74 + self.assertEqual(res, Color(1,0,0,1))
  75 +
  76 + res = getColor('<css function: rgb(255,0,0)>')
  77 + self.assertEqual(res, Color(1,0,0,1))
  78 +
  79 +class UtilsGetSizeTestCase(TestCase):
  80 +
  81 + def test_get_size_simple(self):
  82 + res = getSize('12pt')
  83 + self.assertEqual(res, 12.00)
  84 +
  85 + # Memoized...
  86 + res = getSize('12pt')
  87 + self.assertEqual(res, 12.00)
  88 +
  89 + def test_get_size_for_none(self):
  90 + res = getSize(None, relative='TOKEN')
  91 + self.assertEqual(res, 'TOKEN')
  92 +
  93 + def test_get_size_for_float(self):
  94 + res = getSize(12.00)
  95 + self.assertEqual(res, 12.00)
  96 +
  97 + def test_get_size_for_tuple(self):
  98 + # TODO: This is a really strange case. Probably should not work this way.
  99 + res = getSize(("12", ".12"))
  100 + self.assertEqual(res, 12.12)
  101 +
  102 + def test_get_size_for_cm(self):
  103 + res = getSize("1cm")
  104 + self.assertEqual(res, 28.346456692913385)
  105 +
  106 + def test_get_size_for_mm(self):
  107 + res = getSize("1mm")
  108 + self.assertEqual(res, 2.8346456692913385)
  109 +
  110 + def test_get_size_for_i(self):
  111 + res = getSize("1i")
  112 + self.assertEqual(res, 72.00)
  113 +
  114 + def test_get_size_for_in(self):
  115 + res = getSize("1in")
  116 + self.assertEqual(res, 72.00)
  117 +
  118 + def test_get_size_for_inch(self):
  119 + res = getSize("1in")
  120 + self.assertEqual(res, 72.00)
  121 +
  122 + def test_get_size_for_pc(self):
  123 + res = getSize("1pc")
  124 + self.assertEqual(res, 12.00)
  125 +
  126 + def test_get_size_for_none_str(self):
  127 + res = getSize("none")
  128 + self.assertEqual(res, 0.0)
  129 + res = getSize("0")
  130 + self.assertEqual(res, 0.0)
  131 + res = getSize("auto") # Really?
  132 + self.assertEqual(res, 0.0)

0 comments on commit 0322112

Please sign in to comment.
Something went wrong with that request. Please try again.