Skip to content

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

@Hatyme

Description

@Hatyme

The maximum file size is used here to truncate the asset name

)[-self._max_asset_filename_length :]

and used together here with 'assets' to build a write destination for media assets

content_relative_path = Path(self._assets_path, asset_name)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions