Debian Codegraph @

tests/README.rst

raw
1 .. -*- mode: rst -*-
2
3 Testing
4 =======
5
6 This folder contains the testsuite for ``svglib``. In order to run
7 it before installing the package leave the prefix ``PYTHONPATH=.``
8 in the commands below. Else the testsuite will test an already
9 installed ``svglib`` package.
10
11 For the simplest test open a terminal, change into this folder and
12 execute the following command (assuming you have ``pytest`` installed
13 which is a simple ``pip install pytest``)::
14
15 $ PYTHONPATH=. py.test
16 ======================== test session starts =========================
17 platform darwin -- Python 3…, pytest-3…, py-1…, pluggy-0…
18 rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile:
19 plugins: cov-2…
20 collected 36 items
21
22 tests/test_basic.py ............................
23 tests/test_samples.py .s.s.s.s
24
25 =============== 32 passed, 4 skipped in 49.18 seconds ================
26
27 If for any reason you don't want to install ``pytest`` you can also
28 run the following (which installs ``pytest-runner`` during testing)::
29
30 $ PYTHONPATH=. python setup.py test
31 running pytest
32 running egg_info
33 writing dependency_links to svglib.egg-info/dependency_links.txt
34 writing svglib.egg-info/PKG-INFO
35 writing requirements to svglib.egg-info/requires.txt
36 writing top-level names to svglib.egg-info/top_level.txt
37 reading manifest file 'svglib.egg-info/SOURCES.txt'
38 reading manifest template 'MANIFEST.in'
39 writing manifest file 'svglib.egg-info/SOURCES.txt'
40 running build_ext
41 ======================== test session starts =========================
42 platform darwin -- Python 3…, pytest-3…, py-1…, pluggy-0…
43 rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile:
44 plugins: cov-2…
45 collected 33 items
46
47 tests/test_basic.py .........................
48 tests/test_samples.py .s.s.s.s
49
50 =============== 29 passed, 4 skipped in 38.95 seconds ================
51
52 If you have ``tox`` installed (``pip install tox``) you can simply
53 run the testsuite on Python 3.8 (assuming you have it installed) or on a
54 single version (this will not run with ``conda``, yet, though)::
55
56 $ tox
57 $ tox -e py38
58
59 All will run the entire testsuite and produce result files in PDF
60 format in the subdirectories ``tests/samples`` (here also in PNG),
61 ``tests/wikipedia/flags`` and ``tests/wikipedia/symbols``, if the
62 corresponding SVG input files could be downloaded from the internet
63 at the start of the test or if they are still available from previous
64 runs.
65
66 To clean-up all files generated by ``svglib`` run this (but keep the
67 SVG samples downloaded from the web) run this (output not shown)::
68
69 $ PYTHONPATH=. py.test -v -s --override-ini=python_functions=cleanup
70
71 If you have a ``pytest`` plugin named ``pytest-coverage`` installed
72 (``pip install pytest-coverage``) you can run this to get a simple
73 coverage report (after an additional upfront reset which results in
74 more code being executed and a higher test coverage)::
75
76 $ rm tests/samples/W3C_SVG_12_TinyTestSuite.tar.gz
77 $ rm -rf tests/samples/W3C_SVG_12_TinyTestSuite
78 $ rm -rf tests/samples/wikipedia/flags
79 $ rm -rf tests/samples/wikipedia/symbols
80 $ PYTHONPATH=. py.test --cov=./svglib --cov=tests tests
81 ======================== test session starts =========================
82 platform darwin -- Python 3…, pytest-3…, py-1…, pluggy-0…
83 rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile:
84 plugins: cov-2…
85 collected 36 items
86
87 tests/test_basic.py .........................
88 tests/test_samples.py .s.s.s.s
89
90 ---------- coverage: platform darwin, python 3… -----------
91 Name Stmts Miss Cover
92 -------------------------------------------
93 svglib/__init__.py 0 0 100%
94 svglib/svglib.py 729 28 96%
95 svglib/utils.py 122 12 90%
96 tests/test_basic.py 203 4 98%
97 tests/test_samples.py 249 66 73%
98 -------------------------------------------
99 TOTAL 1303 110 92%
100
101 =============== 32 passed, 4 skipped in 637.65 seconds ===============
102
103 As an experimental feature some of the tests try using a vector
104 conversion tool named `UniConvertor
105 <http://sourceforge.net/projects/uniconvertor>`_
106 (if installed) for producing PDFs for comparison with `svglib`.
107 (This was not used for years, though, during development/testing.)
108
109 Calling ``renderPM.drawToFile()`` in ``TestW3CSVG.test_convert_pdf_png()``
110 is known to raise a ``TypeError`` sometimes in reportlab which was
111 fixed in ``reportlab`` 3.3.26. See
112 https://github.com/deeplook/svglib/issues/47.