remove all read the doc documentation from the repo (#405)

Co-authored-by: Sorin Sbarnea <ssbarnea@redhat.com>
This commit is contained in:
Gleb Nikonorov 2020-12-09 11:30:03 -05:00 committed by GitHub
parent 21fafe40b1
commit 9bd4907682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 395 deletions

View File

@ -1,8 +1,7 @@
pytest-html
===========
pytest-html is a plugin for `pytest <http://pytest.org>`_ that generates a
HTML report for the test results.
pytest-html is a plugin for `pytest <http://pytest.org>`_ that generates a HTML report for test results.
.. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg
:target: https://github.com/pytest-dev/pytest-html/blob/master/LICENSE
@ -23,278 +22,20 @@ HTML report for the test results.
:target: https://codecov.io/gh/pytest-dev/pytest-html
:alt: Codecov
Requirements
Resources
---------
- `Documentation <https://pytest-html.readthedocs.io/en/latest/>`_
- `Release Notes <http://github.com/pytest-dev/pytest-html/blob/master/CHANGES.rst>`_
- `Issue Tracker <http://github.com/pytest-dev/pytest-html/issues>`_
- `Code <http://github.com/pytest-dev/pytest-html/>`_
Contributing
------------
You will need the following prerequisites in order to use pytest-html:
We welcome contributions.
- Python 3.6+ or PyPy3
Installation
------------
To install pytest-html:
.. code-block:: bash
$ pip install pytest-html
Then run your tests with:
.. code-block:: bash
$ pytest --html=report.html
ANSI codes
----------
Note that ANSI code support depends on the
`ansi2html <https://pypi.python.org/pypi/ansi2html/>`_ package. Due to the use
of a less permissive license, this package is not included as a dependency. If
you have this package installed, then ANSI codes will be converted to HTML in
your report.
Creating a self-contained report
--------------------------------
In order to respect the `Content Security Policy (CSP)
<https://developer.mozilla.org/docs/Web/Security/CSP>`_,
several assets such as CSS and images are stored separately by default.
You can alternatively create a self-contained report, which can be more
convenient when sharing your results. This can be done in the following way:
.. code-block:: bash
$ pytest --html=report.html --self-contained-html
Images added as files or links are going to be linked as external resources,
meaning that the standalone report HTML-file may not display these images
as expected.
The plugin will issue a warning when adding files or links to the standalone report.
Enhancing reports
-----------------
Appearance
~~~~~~~~~~
Custom CSS (Cascasding Style Sheets) can be passed on the command line using
the :code:`--css` option. These will be applied in the order specified, and can
be used to change the appearance of the report.
.. code-block:: bash
$ pytest --html=report.html --css=highcontrast.css --css=accessible.css
Report Title
~~~~~~~~~~~~
By default report title will be the filename of the report, you can edit it by using the :code:`pytest_html_report_title` hook:
.. code-block:: python
def pytest_html_report_title(report):
report.title = "My very own title!"
Environment
~~~~~~~~~~~
The *Environment* section is provided by the `pytest-metadata
<https://pypi.python.org/pypi/pytest-metadata/>`_ plugin, and can be accessed
via the :code:`pytest_configure` hook:
.. code-block:: python
def pytest_configure(config):
config._metadata["foo"] = "bar"
The generated table will be sorted alphabetically unless the metadata is a
:code:`collections.OrderedDict`.
Additional summary information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can edit the *Summary* section by using the :code:`pytest_html_results_summary` hook:
.. code-block:: python
from py.xml import html
def pytest_html_results_summary(prefix, summary, postfix):
prefix.extend([html.p("foo: bar")])
Extra content
~~~~~~~~~~~~~
You can add details to the HTML reports by creating an 'extra' list on the
report object. Here are the types of extra content that can be added:
========== ============================================
Type Example
========== ============================================
Raw HTML ``extra.html('<div>Additional HTML</div>')``
`JSON`_ ``extra.json({'name': 'pytest'})``
Plain text ``extra.text('Add some simple Text')``
URL ``extra.url('http://www.example.com/')``
Image ``extra.image(image, mime_type='image/gif', extension='gif')``
Image ``extra.image('/path/to/file.png')``
Image ``extra.image('http://some_image.png')``
========== ============================================
**Note**: When adding an image from file, the path can be either absolute
or relative.
**Note**: When using ``--self-contained-html``, images added as files or links
may not work as expected, see section `Creating a self-contained report`_ for
more info.
There are also convenient types for several image formats:
============ ====================
Image format Example
============ ====================
PNG ``extra.png(image)``
JPEG ``extra.jpg(image)``
SVG ``extra.svg(image)``
============ ====================
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:
.. code-block:: python
import pytest
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
pytest_html = item.config.pluginmanager.getplugin("html")
outcome = yield
report = outcome.get_result()
extra = getattr(report, "extra", [])
if report.when == "call":
# always add url to report
extra.append(pytest_html.extras.url("http://www.example.com/"))
xfail = hasattr(report, "wasxfail")
if (report.skipped and xfail) or (report.failed and not xfail):
# only add additional html on failure
extra.append(pytest_html.extras.html("<div>Additional HTML</div>"))
report.extra = extra
You can also specify the :code:`name` argument for all types other than :code:`html` which will change the title of the
created hyper link:
.. code-block:: python
extra.append(pytest_html.extras.text("some string", name="Different title"))
It is also possible to use the fixture :code:`extra` to add content directly
in a test function without implementing hooks. These will generally end up
before any extras added by plugins.
.. code-block:: python
from pytest_html import extras
def test_extra(extra):
extra.append(extras.text("some string"))
Modifying the results table
~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can modify the columns by implementing custom hooks for the header and
rows. The following example :code:`conftest.py` adds a description column with
the test function docstring, adds a sortable time column, and removes the links
column:
.. code-block:: python
from datetime import datetime
from py.xml import html
import pytest
def pytest_html_results_table_header(cells):
cells.insert(2, html.th("Description"))
cells.insert(1, html.th("Time", class_="sortable time", col="time"))
cells.pop()
def pytest_html_results_table_row(report, cells):
cells.insert(2, html.td(report.description))
cells.insert(1, html.td(datetime.utcnow(), class_="col-time"))
cells.pop()
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.description = str(item.function.__doc__)
You can also remove results by implementing the
:code:`pytest_html_results_table_row` hook and removing all cells. The
following example removes all passed results from the report:
.. code-block:: python
def pytest_html_results_table_row(report, cells):
if report.passed:
del cells[:]
The log output and additional HTML can be modified by implementing the
:code:`pytest_html_results_html` hook. The following example replaces all
additional HTML and log output with a notice that the log is empty:
.. code-block:: python
from py.xml import html
def pytest_html_results_table_html(report, data):
if report.passed:
del data[:]
data.append(html.div("No log output captured.", class_="empty log"))
Display options
---------------
By default, all rows in the **Results** table will be expanded except those that have :code:`Passed`.
This behavior can be customized either with a query parameter: :code:`?collapsed=Passed,XFailed,Skipped`
or by setting the :code:`render_collapsed` in a configuration file (pytest.ini, setup.cfg, etc).
.. code-block:: ini
[pytest]
render_collapsed = True
**NOTE:** Setting :code:`render_collapsed` will, unlike the query parameter, affect all statuses.
The formatting of the timestamp used in the :code:`Durations` column can be modified by setting :code:`duration_formatter`
on the :code:`report` attribute. All `time.strftime`_ formatting directives are supported. In addition, it is possible
to supply :code:`%f` to get duration milliseconds. If this value is not set, the values in the :code:`Durations` column are
displayed in :code:`%S.%f` format where :code:`%S` is the total number of seconds a test ran for.
Below is an example of a :code:`conftest.py` file setting :code:`duration_formatter`:
.. code-block:: python
import pytest
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
setattr(report, "duration_formatter", "%H:%M:%S.%f")
**NOTE**: Milliseconds are always displayed with a precision of 2
To learn more, see `Development <https://pytest-html.readthedocs.io/en/latest/development.html>`_
Screenshots
-----------
@ -302,21 +43,3 @@ Screenshots
.. image:: https://cloud.githubusercontent.com/assets/122800/11952194/62daa964-a88e-11e5-9745-2aa5b714c8bb.png
:target: https://cloud.githubusercontent.com/assets/122800/11951695/f371b926-a88a-11e5-91c2-499166776bd3.png
:alt: Enhanced HTML report
Contributing
------------
We welcome contributions.
To learn more, see `Development <https://github.com/pytest-dev/pytest-html/blob/master/development.rst>`_
Resources
---------
- `Release Notes <http://github.com/pytest-dev/pytest-html/blob/master/CHANGES.rst>`_
- `Issue Tracker <http://github.com/pytest-dev/pytest-html/issues>`_
- `Code <http://github.com/pytest-dev/pytest-html/>`_
.. _JSON: http://json.org/
.. _time.strftime: https://docs.python.org/3/library/time.html#time.strftime

View File

@ -1,106 +0,0 @@
Development
===========
To contribute to `pytest-html` you can use `Pipenv`_ to manage
a python virtual environment and `pre-commit <https://pre-commit.com/>`_ to help you with
styling and formatting.
To setup the virtual environment and pre-commit, run:
.. code-block:: bash
$ pipenv install --dev
$ pipenv run pre-commit install
If you're not using `Pipenv`_, to install `pre-commit`, run:
.. code-block:: bash
$ pip install pre-commit
$ pre-commit install
Automated Testing
-----------------
All pull requests and merges are tested in `GitHub Actions <https://github.com/pytest-dev/pytest-html/actions>`_
which are defined inside ``.github`` folder.
To retrigger CI to run again for a pull request, you either use dropdown
option, close and reopen pull-request or to just update the branch containing
it.
You can do this with `git commit --allow-empty`
Running Tests - Python
----------------------
You will need `Tox <https://tox.readthedocs.io>`_ installed to run the tests
against the supported Python versions. If you're using `Pipenv`_ it will be
installed for you.
With `Pipenv`_, run:
.. code-block:: bash
$ pipenv run tox
Otherwise, to install and run, do:
.. code-block:: bash
$ pip install tox
$ tox
Running Tests - JavaScript
--------------------------
You will need `npm <https://www.npmjs.com>`_ installed to run the JavaScript tests.
Internally, we use `Grunt <https://gruntjs.com>`_ and `QUnit <https://qunitjs.com>`_ to run the tests.
Once ``npm`` is installed, you can install all needed dependencies by running:
.. code-block:: bash
$ npm install
Run the following to execute the tests:
.. code-block:: bash
$ npm test
SASS/SCSS/CSS
-------------
You will need `npm <https://www.npmjs.com>`_ installed to compile the CSS,
which is generated via `SASS/SCSS <https://sass-lang.com/>`_.
Once ``npm`` is installed, you can install all needed dependencies by running:
.. code-block:: bash
$ npm install
Run the following to generate the CSS:
.. code-block:: bash
$ npm run build:css
Releasing a new version
-----------------------
Follow these steps to release a new version of the project:
#. Update your local master with the upstream master (``git pull --rebase upstream master``)
#. Create a new branch
#. Update ``CHANGES.rst`` with the new version, today's date, and all changes/new features
#. Commit and push the new branch and then create a new pull request
#. Wait for tests and reviews and then merge the branch
#. Once merged, update your local master again (``git pull --rebase upstream master``)
#. Tag the release with the new release version (``git tag v<new tag>``)
#. Push the tag (``git push upstream --tags``)
#. Done. Check `CI <https://github.com/pytest-dev/pytest-html/actions>`_ for release progress.
.. _Pipenv: https://pipenv.pypa.io/en/latest/