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

path too long on windows when saving report with screenshots #124

Closed
ngavrish opened this issue Jul 11, 2017 · 3 comments
Closed

path too long on windows when saving report with screenshots #124

ngavrish opened this issue Jul 11, 2017 · 3 comments
Labels
bug This issue/PR relates to a bug. help wanted

Comments

@ngavrish
Copy link

I have following code to generate screenshots in reports

        if xfail or report.failed:
            **extra.append(pytest_html.extras.image(pytest.driver.get_screenshot_as_base64(), ''))**
            extra.append(pytest_html.extras.html('<div><h2 style="color: red; ">{}</h2></div>'.format(test_name)))
        elif report.passed:
            extra.append(pytest_html.extras.html(
                '<div><h2 style="color: black; text-decoration: underline">{}</h2></div>'.format(test_name)))
        pytest_html.extras.html('<div style="color: black; margin: 10px;">'.format(test_name))
        for step in test_steps:
            extra.append(pytest_html.extras.html('<p style="margin: 5px;">{}</p>'.format(step)))
        pytest_html.extras.html('</div>')
        report.extra = extra

And you have line in plugin.py where you get file content and validate if its path. And in my case file content contains binary representation of image. When windows is trying to validate this long path, it fails into INTERNAL ERROR.

INTERNALERROR> File "c:\python36\lib\site-packages\pytest_html\plugin.py", line 112, in init
INTERNALERROR> self.append_extra_html(extra, extra_index, test_index)
INTERNALERROR> File "c:\python36\lib\site-packages\pytest_html\plugin.py", line 164, in append_extra_html
INTERNALERROR> os.path.isfile(content):
INTERNALERROR> File "c:\python36\lib\genericpath.py", line 30, in isfile
INTERNALERROR> st = os.stat(path)
INTERNALERROR> ValueError: stat: path too long for Windows

@davehunt
Copy link
Collaborator

Thanks for the bug report. It sounds like we need to catch this exception.

@davehunt davehunt added bug This issue/PR relates to a bug. help wanted labels Jul 17, 2017
@camillake
Copy link

@davehunt This issue could be resolved, please refer to pytest-dev/pytest#291. More about windows path: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

pinkie1378 added a commit to pinkie1378/pytest-html that referenced this issue Nov 8, 2017
pinkie1378 added a commit to pinkie1378/pytest-html that referenced this issue Nov 8, 2017
pinkie1378 added a commit to pinkie1378/pytest-html that referenced this issue Jan 3, 2018
@davehunt
Copy link
Collaborator

davehunt commented Jan 4, 2018

pytest-html 1.16.1 has been released with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug. help wanted
Projects
None yet
Development

No branches or pull requests

3 participants