Skip to content

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

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

Open
Hatyme opened this issue Apr 17, 2025 · 0 comments

Comments

@Hatyme
Copy link

Hatyme commented Apr 17, 2025

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
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

No branches or pull requests

1 participant