pytest-dev / pytest-dev/pytest-html

_max_asset_filename_length of BaseReport does not account for prefixed 'assets/'

Open
#906 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
779
Forks
260
PR merge metrics
No merged PRs in 30d

Description

The maximum file size is used here to truncate the asset name
https://github.com/pytest-dev/pytest-html/blob/4b88ee41bdbb5666b31dffd366608f735565b329/src/pytest_html/basereport.py#L50

and used together here with 'assets' to build a write destination for media assets
https://github.com/pytest-dev/pytest-html/blob/4b88ee41bdbb5666b31dffd366608f735565b329/src/pytest_html/report.py#L39

on windows systems with a 256 character path length this will cause the write to silently fail and the following read when creating the report to not find the given asset.

conftest.py

@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
    _ = call
    outcome = yield

    report = outcome.get_result()
    extra = getattr(report, 'extra', list())
    report.extra = extra
    browser: WebDriver = item.funcargs.get('browser', None)

    screenshot = browser.get_screenshot_as_base64()
    extra.append(pytest_html.extras.png(screenshot))

test_stuff.py

def test_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(browser):
    assert False

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked calculations in src/pytest_html/basereport.py and src/pytest_html/report.py, then run the provided long-test-name screenshot reproduction on Windows or with an equivalent path-length limit. Done means media assets still write and are read when the generated report uses the prefixed assets/ destination.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.