Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

1.7.5
-----

- escape screenshot paths for path separators (bubenkoff)


1.7.4
-----

Expand Down
2 changes: 1 addition & 1 deletion pytest_splinter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""pytest-splinter package."""
__version__ = '1.7.4'
__version__ = '1.7.5'
5 changes: 3 additions & 2 deletions pytest_splinter/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,9 @@ def browser_screenshot(

classname = '.'.join(names[:-1])
screenshot_dir = os.path.join(splinter_screenshot_dir, classname)
screenshot_file_name_format = '{0}-{1}.{{format}}'.format(
names[-1][:128 - len(name) - 5], name)
screenshot_file_name_format = '{0}.{{format}}'.format(
'{0}-{1}'.format(names[-1][:128 - len(name) - 5], name).replace(os.path.sep, '-')
)
screenshot_file_name = screenshot_file_name_format.format(format='png')
screenshot_html_file_name = screenshot_file_name_format.format(format='html')
if not slaveoutput:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,28 @@ def test_screenshot(simple_page, browser):
content = testdir.tmpdir.join('test_browser_screenshot_normal', 'test_screenshot-browser.html').read()
assert content.replace('\n', '') == simple_page_content.replace('\n', '')
assert testdir.tmpdir.join('test_browser_screenshot_normal', 'test_screenshot-browser.png')


def test_browser_screenshot_escaped(testdir, simple_page_content):
"""Test making screenshots on test failure with escaped test names.

Normal test run.
"""
testdir.inline_runsource("""
import pytest

@pytest.fixture
def simple_page(httpserver, browser):
httpserver.serve_content(
'''{0}''', code=200, headers={{'Content-Type': 'text/html'}})
browser.visit(httpserver.url)

@pytest.mark.parametrize('param', ['escaped/param'])
def test_screenshot(simple_page, browser, param):
assert False
""".format(simple_page_content), "-vl", "-r w")

content = testdir.tmpdir.join(
'test_browser_screenshot_escaped', 'test_screenshot[escaped-param]-browser.html').read()
assert content.replace('\n', '') == simple_page_content.replace('\n', '')
assert testdir.tmpdir.join('test_browser_screenshot_escaped', 'test_screenshot[escaped-param]-browser.png')