Skip to content

Chore: Pluralize extra #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/pytest_html/nextgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ def pytest_runtest_logreport(self, report):

test_index = hasattr(report, "rerun") and report.rerun + 1 or 0

# TODO rename to "extras" since list
report_extras = getattr(report, "extra", [])
report_extras = getattr(report, "extras", [])
for extra_index, extra in enumerate(report_extras):
content = extra["content"]
asset_name = self._asset_filename(test_id, extra_index, test_index, extra['extension'])
Expand Down
26 changes: 24 additions & 2 deletions src/pytest_html/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import pytest
import warnings
from pathlib import Path

from . import extras # noqa: F401
Expand Down Expand Up @@ -114,8 +115,8 @@ def pytest_runtest_makereport(item, call):
report = outcome.get_result()
if report.when == "call":
fixture_extras = getattr(item.config, "extras", [])
plugin_extras = getattr(report, "extra", [])
report.extra = fixture_extras + plugin_extras
plugin_extras = getattr(report, "extras", [])
report.extras = fixture_extras + plugin_extras


@pytest.fixture
Expand All @@ -130,6 +131,27 @@ def extra(pytestconfig):
def test_foo(extra):
extra.append(pytest_html.extras.url("https://www.example.com/"))
"""
warnings.warn(
"The 'extra' fixture is deprecated and will be removed in a future release, use 'extras' instead.",
DeprecationWarning
)
pytestconfig.extras = []
yield pytestconfig.extras
del pytestconfig.extras[:]


@pytest.fixture
def extras(pytestconfig):
"""Add details to the HTML reports.

.. code-block:: python

import pytest_html


def test_foo(extras):
extras.append(pytest_html.extras.url("https://www.example.com/"))
"""
pytestconfig.extras = []
yield pytestconfig.extras
del pytestconfig.extras[:]