Add details of extra content options to README

This commit is contained in:
Nicolas Mauchle 2016-12-10 14:08:23 +01:00 committed by Dave Hunt
parent f84482bc6a
commit 1595e2cc37
No known key found for this signature in database
GPG Key ID: 4000D32ABB02F959
1 changed files with 15 additions and 1 deletions

View File

@ -78,7 +78,21 @@ You can add change the *Environment* section of the report by modifying
request.config._environment.append(('foo', 'bar'))
You can add details to the HTML reports by creating an 'extra' list on the
report object. The following example adds the various types of extras using a
report object. There are five different extras you can add:
- HTML: ``report.extra = [extra.html('<div>Additional HTML</div>')]``
- JSON: ``report.extra = [extra.json({'name': 'pytest'})]``
- TEXT: ``report.extra = [extra.text('Add some simple Text')]``
- URL: ``report.extra = [extra.url('http://www.example.com/')]``
PNG, JPEG and SVG are predifend images types but you can add any image type you want.
- PNG: ``report.extra = [extra.png(image)]``
- JPG: ``report.extra = [extra.jpg(image)]``
- SVG: ``report.extra = [extra.svg(image)]``
- Any image type: ``report.extra = [extra.image(image, mime_type='image/gif', extension='gif')]``
The following example adds the various types of extras using a
:code:`pytest_runtest_makereport` hook, which can be implemented in a plugin or
conftest.py file: