Skip to content
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

update: duration_format renders deprecation warning #589

Merged

Conversation

BeyondEvil
Copy link
Contributor

@BeyondEvil BeyondEvil commented Mar 8, 2023

Remove the duration_formatter and warn if it's used as it's no longer functional in 4.x.

@BeyondEvil BeyondEvil changed the base branch from master to next-gen March 8, 2023 18:12
@BeyondEvil BeyondEvil changed the title Beyondevil/remove duration format update: duration_format renders deprecation warning Mar 8, 2023
@BeyondEvil BeyondEvil force-pushed the beyondevil/remove-duration-format branch 2 times, most recently from fdbdd02 to 6f6ae0c Compare March 18, 2023 22:58
@BeyondEvil BeyondEvil marked this pull request as ready for review March 18, 2023 22:59
@BeyondEvil BeyondEvil force-pushed the beyondevil/remove-duration-format branch 2 times, most recently from 08ff103 to ed94da3 Compare March 18, 2023 23:01
@BeyondEvil
Copy link
Contributor Author

Why is the test failing?

From the output the deprecation warning is being emitted, so why is it failing?

https://github.com/pytest-dev/pytest-html/actions/runs/4457713820/jobs/7828947129?pr=589#step:10:335

Stacktrace

testing/test_unit.py ============================= test session starts ==============================
platform linux -- Python 3.10.10, pytest-7.2.2, pluggy-1.0.0
rootdir: /tmp/pytest-of-runner/pytest-0/test_duration_format_deprecation_warning0
plugins: html-4.0.0rc0, metadata-2.0.4, cov-4.0.0, xdist-3.2.1, mock-3.10.0, rerunfailures-11.1.2
collected 1 item
test_duration_format_deprecation_warning.py F
=================================== FAILURES ===================================
__________________________________ test_pass ___________________________________
def test_pass():
with pytest.warns(DeprecationWarning) as record:

      assert len(record) == 1

E assert 0 == 1
E + where 0 = len(WarningsChecker(record=True))
test_duration_format_deprecation_warning.py:4: AssertionError
=============================== warnings summary ===============================
test_duration_format_deprecation_warning.py::test_pass
test_duration_format_deprecation_warning.py::test_pass
test_duration_format_deprecation_warning.py::test_pass
/home/runner/work/pytest-html/pytest-html/.tox/py310-cov/lib/python3.10/site-packages/pytest_html/nextgen.py:244: DeprecationWarning: 'duration_formatter' has been removed and no longer has any effect!
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

  • Generated html report: file:///tmp/pytest-of-runner/pytest-0/test_duration_format_deprecation_warning0/report.html -
    =========================== short test summary info ============================
    FAILED test_duration_format_deprecation_warning.py::test_pass - assert 0 == 1
    ======================== 1 failed, 3 warnings in 0.02s =========================
    F
    =================================== FAILURES ===================================
    ___________________ test_duration_format_deprecation_warning ___________________
    pytester = <Pytester PosixPath('/tmp/pytest-of-runner/pytest-0/test_duration_format_deprecation_warning0')>
    def test_duration_format_deprecation_warning(pytester):
    pytester.makeconftest(
    """
    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")
    """
    )
    pytester.makepyfile(
    """
    import pytest
    def test_pass():
    with pytest.warns(DeprecationWarning) as record:
    assert len(record) == 1
    """
    )
    result = run(pytester)
  assert result.ret == 0

E assert <ExitCode.TESTS_FAILED: 1> == 0
E + where <ExitCode.TESTS_FAILED: 1> = <RunResult ret=ExitCode.TESTS_FAILED len(stdout.lines)=30 len(stderr.lines)=0 duration=0.12s>.ret
/home/runner/work/pytest-html/pytest-html/testing/test_unit.py:29: AssertionError

@BeyondEvil BeyondEvil force-pushed the beyondevil/remove-duration-format branch 10 times, most recently from cc97e9a to 377514a Compare March 19, 2023 14:55
@BeyondEvil BeyondEvil force-pushed the beyondevil/remove-duration-format branch from 377514a to f46ed98 Compare March 19, 2023 15:07
@BeyondEvil BeyondEvil merged commit d02dac0 into pytest-dev:next-gen Mar 19, 2023
@BeyondEvil BeyondEvil deleted the beyondevil/remove-duration-format branch March 19, 2023 15:16
BeyondEvil added a commit to BeyondEvil/pytest-html that referenced this pull request Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant