.. -*- mode: rst -*- Testing ======= This folder contains the testsuite for ``svglib``. In order to run it before installing the package leave the prefix ``PYTHONPATH=.`` in the commands below. Else the testsuite will test an already installed ``svglib`` package. For the simplest test open a terminal, change into this folder and execute the following command (assuming you have ``pytest`` installed which is a simple ``pip install pytest``):: $ PYTHONPATH=. py.test ======================== test session starts ========================= platform darwin -- Python 3…, pytest-3…, py-1…, pluggy-0… rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile: plugins: cov-2… collected 36 items tests/test_basic.py ............................ tests/test_samples.py .s.s.s.s =============== 32 passed, 4 skipped in 49.18 seconds ================ If for any reason you don't want to install ``pytest`` you can also run the following (which installs ``pytest-runner`` during testing):: $ PYTHONPATH=. python setup.py test running pytest running egg_info writing dependency_links to svglib.egg-info/dependency_links.txt writing svglib.egg-info/PKG-INFO writing requirements to svglib.egg-info/requires.txt writing top-level names to svglib.egg-info/top_level.txt reading manifest file 'svglib.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'svglib.egg-info/SOURCES.txt' running build_ext ======================== test session starts ========================= platform darwin -- Python 3…, pytest-3…, py-1…, pluggy-0… rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile: plugins: cov-2… collected 33 items tests/test_basic.py ......................... tests/test_samples.py .s.s.s.s =============== 29 passed, 4 skipped in 38.95 seconds ================ If you have ``tox`` installed (``pip install tox``) you can simply run the testsuite on Python 3.8 (assuming you have it installed) or on a single version (this will not run with ``conda``, yet, though):: $ tox $ tox -e py38 All will run the entire testsuite and produce result files in PDF format in the subdirectories ``tests/samples`` (here also in PNG), ``tests/wikipedia/flags`` and ``tests/wikipedia/symbols``, if the corresponding SVG input files could be downloaded from the internet at the start of the test or if they are still available from previous runs. To clean-up all files generated by ``svglib`` run this (but keep the SVG samples downloaded from the web) run this (output not shown):: $ PYTHONPATH=. py.test -v -s --override-ini=python_functions=cleanup If you have a ``pytest`` plugin named ``pytest-coverage`` installed (``pip install pytest-coverage``) you can run this to get a simple coverage report (after an additional upfront reset which results in more code being executed and a higher test coverage):: $ rm tests/samples/W3C_SVG_12_TinyTestSuite.tar.gz $ rm -rf tests/samples/W3C_SVG_12_TinyTestSuite $ rm -rf tests/samples/wikipedia/flags $ rm -rf tests/samples/wikipedia/symbols $ PYTHONPATH=. py.test --cov=./svglib --cov=tests tests ======================== test session starts ========================= platform darwin -- Python 3…, pytest-3…, py-1…, pluggy-0… rootdir: /Users/dinu/repos/github/deeplook/svglib, inifile: plugins: cov-2… collected 36 items tests/test_basic.py ......................... tests/test_samples.py .s.s.s.s ---------- coverage: platform darwin, python 3… ----------- Name Stmts Miss Cover ------------------------------------------- svglib/__init__.py 0 0 100% svglib/svglib.py 729 28 96% svglib/utils.py 122 12 90% tests/test_basic.py 203 4 98% tests/test_samples.py 249 66 73% ------------------------------------------- TOTAL 1303 110 92% =============== 32 passed, 4 skipped in 637.65 seconds =============== As an experimental feature some of the tests try using a vector conversion tool named `UniConvertor `_ (if installed) for producing PDFs for comparison with `svglib`. (This was not used for years, though, during development/testing.) Calling ``renderPM.drawToFile()`` in ``TestW3CSVG.test_convert_pdf_png()`` is known to raise a ``TypeError`` sometimes in reportlab which was fixed in ``reportlab`` 3.3.26. See https://github.com/deeplook/svglib/issues/47.