Skip to content

Release v1.22.1 #251

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

Merged
merged 1 commit into from
Nov 18, 2019
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
14 changes: 14 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Release Notes
-------------

**1.22.1 (2019-10-05)**

* Properly check for presence of CSS file. (`#246 <https://github.com/pytest-dev/pytest-html/issues/246>`_)

* Thanks to `@wanam <https://github.com/wanam>`_ for reporting, and `@krzysztof-pawlik-gat <https://github.com/krzysztof-pawlik-gat>`_ for the fix

* Added support for UTF-8 display. (`#244 <https://github.com/pytest-dev/pytest-html/pull/244>`_)

* Thanks to `@Izhu666 <https://github.com/lzhu666>`_ for the PR

* Fix initial sort on column. (`#247 <https://github.com/pytest-dev/pytest-html/issues/247>`_)

* Thanks to `@wanam <https://github.com/wanam>`_ for reporting and fixing

**1.22.0 (2019-08-06)**

* Refactor assets naming to be more readable and OS safe.
Expand Down
7 changes: 5 additions & 2 deletions pytest_html/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def pytest_configure(config):
htmlpath = config.getoption("htmlpath")
if htmlpath:
for csspath in config.getoption("css"):
open(csspath)
if not os.path.exists(csspath):
raise IOError(
"No such file or directory: '{csspath}'".format(csspath=csspath)
)
if not hasattr(config, "slaveinput"):
# prevent opening htmlpath on slave nodes (xdist)
config._html = HTMLReport(htmlpath, config)
Expand Down Expand Up @@ -114,7 +117,7 @@ def __init__(self, logfile, config):

class TestResult:
def __init__(self, outcome, report, logfile, config):
self.test_id = report.nodeid
self.test_id = report.nodeid.encode("utf-8").decode("unicode_escape")
if getattr(report, "when", "call") != "call":
self.test_id = "::".join([report.nodeid, report.when])
self.time = getattr(report, "duration", 0.0)
Expand Down
2 changes: 1 addition & 1 deletion pytest_html/resources/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function init () {

show_filters();

toggle_sort_states(find('.initial-sort'));
sort_column(find('.initial-sort'));

find_all('.sortable').forEach(function(elem) {
elem.addEventListener("click",
Expand Down
21 changes: 19 additions & 2 deletions testing/test_pytest_html.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Expand Down Expand Up @@ -816,7 +817,7 @@ def test_pass(): pass
assert re.search(regex_error, html) is not None

@pytest.mark.parametrize("colors", [(["red"]), (["green", "blue"])])
def test_css(self, testdir, colors):
def test_css(self, testdir, recwarn, colors):
testdir.makepyfile("def test_pass(): pass")
css = {}
cssargs = []
Expand All @@ -827,17 +828,33 @@ def test_css(self, testdir, colors):
cssargs.extend(["--css", path])
result, html = run(testdir, "report.html", "--self-contained-html", *cssargs)
assert result.ret == 0
assert len(recwarn) == 0
for k, v in css.items():
assert str(v["path"]) in html
assert v["style"] in html

def test_css_invalid(self, testdir):
def test_css_invalid(self, testdir, recwarn):
testdir.makepyfile("def test_pass(): pass")
result = testdir.runpytest("--html", "report.html", "--css", "style.css")
assert result.ret
assert len(recwarn) == 0
assert "No such file or directory: 'style.css'" in result.stderr.str()

def test_css_invalid_no_html(self, testdir):
testdir.makepyfile("def test_pass(): pass")
result = testdir.runpytest("--css", "style.css")
assert result.ret == 0

def test_report_display_utf8(self, testdir):
testdir.makepyfile(
"""
# coding: utf-8
import pytest
@pytest.mark.parametrize("utf8", [("测试用例名称")])
def test_pass(utf8):
assert True
"""
)
result, html = run(testdir)
assert result.ret == 0
assert r"\u6d4b\u8bd5\u7528\u4f8b\u540d\u79f0" not in html