Hello community, here is the log from the commit of package python-pytest-html for openSUSE:Factory checked in at 2019-07-03 15:15:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-html (Old) and /work/SRC/openSUSE:Factory/.python-pytest-html.new.4615 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-html" Wed Jul 3 15:15:00 2019 rev:3 rq:713053 version:1.21.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-html/python-pytest-html.changes 2019-02-27 15:10:06.418374496 +0100 +++ /work/SRC/openSUSE:Factory/.python-pytest-html.new.4615/python-pytest-html.changes 2019-07-03 15:15:02.258968542 +0200 @@ -1,0 +2,9 @@ +Tue Jul 2 12:29:33 UTC 2019 - Tomáš Chvátal <tchva...@suse.com> + +- Update to 1.21.1: + * Fix issue with assets filenames being too long. + * Allow opening generated html report in browser (@ssbarnea) + * Handle when report title is stored as an environment variable (@BeyondEvil) + * Change assets naming method (@SunInJuly) + +------------------------------------------------------------------- Old: ---- pytest-html-1.20.0.tar.gz New: ---- pytest-html-1.21.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-html.spec ++++++ --- /var/tmp/diff_new_pack.L9fMYR/_old 2019-07-03 15:15:03.290970641 +0200 +++ /var/tmp/diff_new_pack.L9fMYR/_new 2019-07-03 15:15:03.302970665 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pytest-html -Version: 1.20.0 +Version: 1.21.1 Release: 0 Summary: pytest plugin for generating HTML reports License: MPL-2.0 ++++++ pytest-html-1.20.0.tar.gz -> pytest-html-1.21.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-html-1.20.0/.gitignore new/pytest-html-1.21.1/.gitignore --- old/pytest-html-1.20.0/.gitignore 2019-01-14 18:53:41.000000000 +0100 +++ new/pytest-html-1.21.1/.gitignore 2019-06-19 21:40:20.000000000 +0200 @@ -30,3 +30,5 @@ ##Tests JS node_modules/ + +Pipfile diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-html-1.20.0/CHANGES.rst new/pytest-html-1.21.1/CHANGES.rst --- old/pytest-html-1.20.0/CHANGES.rst 2019-01-14 18:53:41.000000000 +0100 +++ new/pytest-html-1.21.1/CHANGES.rst 2019-06-19 21:40:20.000000000 +0200 @@ -1,6 +1,20 @@ Release Notes ------------- +**1.21.1 (2019-06-19)** + +* Fix issue with assets filenames being too long. + + * Thanks to `@D3X <https://github.com/D3X>`_ for reporting and providing a fix + +**1.21.0 (2019-06-17)** + +* Allow opening generated html report in browser (`@ssbarnea <https://github.com/ssbarnea>`_) + +* Handle when report title is stored as an environment variable (`@BeyondEvil <https://github.com/BeyondEvil>`_) + +* Change assets naming method (`@SunInJuly <https://github.com/SunInJuly>`_) + **1.20.0 (2019-01-14)** * Tests running with Pytest 4.0 and Python 3.7 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-html-1.20.0/PKG-INFO new/pytest-html-1.21.1/PKG-INFO --- old/pytest-html-1.20.0/PKG-INFO 2019-01-14 18:54:02.000000000 +0100 +++ new/pytest-html-1.21.1/PKG-INFO 2019-06-19 21:40:40.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pytest-html -Version: 1.20.0 +Version: 1.21.1 Summary: pytest plugin for generating HTML reports Home-page: https://github.com/pytest-dev/pytest-html Author: Dave Hunt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-html-1.20.0/pytest_html/plugin.py new/pytest-html-1.21.1/pytest_html/plugin.py --- old/pytest-html-1.20.0/pytest_html/plugin.py 2019-01-14 18:53:41.000000000 +0100 +++ new/pytest-html-1.21.1/pytest_html/plugin.py 2019-06-19 21:40:20.000000000 +0200 @@ -145,12 +145,19 @@ def create_asset(self, content, extra_index, test_index, file_extension, mode='w'): + hash_key = ''.join([self.test_id, str(extra_index), - str(test_index)]).encode('utf-8') + str(test_index)]) hash_generator = hashlib.md5() - hash_generator.update(hash_key) - asset_file_name = '{0}.{1}'.format(hash_generator.hexdigest(), - file_extension) + hash_generator.update(hash_key.encode('utf-8')) + hex_digest = hash_generator.hexdigest() + # 255 is the common max filename length on various filesystems, + # we subtract hash length, file extension length and 2 more + # characters for the underscore and dot + max_length = 255 - len(hex_digest) - len(file_extension) - 2 + asset_file_name = '{0}_{1}.{2}'.format(hash_key[:max_length], + hex_digest, + file_extension) asset_path = os.path.join(os.path.dirname(self.logfile), 'assets', asset_file_name) if not os.path.exists(os.path.dirname(asset_path)): @@ -430,7 +437,7 @@ body = html.body( html.script(raw(main_js)), - html.h1(os.path.basename(session.config.option.htmlpath)), + html.h1(os.path.basename(self.logfile)), html.p('Report generated on {0} at {1} by '.format( generated.strftime('%d-%b-%Y'), generated.strftime('%H:%M:%S')), @@ -519,5 +526,6 @@ self._save_report(report_content) def pytest_terminal_summary(self, terminalreporter): - terminalreporter.write_sep('-', 'generated html file: {0}'.format( - self.logfile)) + terminalreporter.write_sep( + '-', + 'generated html file: file://{0}'.format(self.logfile)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-html-1.20.0/pytest_html.egg-info/PKG-INFO new/pytest-html-1.21.1/pytest_html.egg-info/PKG-INFO --- old/pytest-html-1.20.0/pytest_html.egg-info/PKG-INFO 2019-01-14 18:54:01.000000000 +0100 +++ new/pytest-html-1.21.1/pytest_html.egg-info/PKG-INFO 2019-06-19 21:40:40.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pytest-html -Version: 1.20.0 +Version: 1.21.1 Summary: pytest plugin for generating HTML reports Home-page: https://github.com/pytest-dev/pytest-html Author: Dave Hunt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-html-1.20.0/testing/test_pytest_html.py new/pytest-html-1.21.1/testing/test_pytest_html.py --- old/pytest-html-1.20.0/testing/test_pytest_html.py 2019-01-14 18:53:41.000000000 +0100 +++ new/pytest-html-1.21.1/testing/test_pytest_html.py 2019-06-19 21:40:20.000000000 +0200 @@ -21,9 +21,12 @@ def run(testdir, path='report.html', *args): path = testdir.tmpdir.join(path) result = testdir.runpytest('--html', path, *args) + return result, read_html(path) + + +def read_html(path): with open(str(path)) as f: - html = f.read() - return result, html + return f.read() def assert_results_by_outcome(html, test_outcome, test_outcome_number, @@ -193,6 +196,25 @@ report_title = "<h1>{0}</h1>".format(report_name) assert report_title in html + def test_report_title_addopts_env_var(self, testdir, monkeypatch): + report_location = "REPORT_LOCATION" + report_name = "MuhReport" + monkeypatch.setenv(report_location, report_name) + testdir.makefile( + ".ini", + pytest=""" + [pytest] + addopts = --html ${0} + """.format( + report_location + ), + ) + testdir.makepyfile('def test_pass(): pass') + result = testdir.runpytest() + assert result.ret == 0 + report_title = "<h1>{0}</h1>".format(report_name) + assert report_title in read_html(report_name) + def test_resources_inline_css(self, testdir): testdir.makepyfile('def test_pass(): pass') result, html = run(testdir, 'report.html', '--self-contained-html') @@ -383,12 +405,12 @@ testdir.makepyfile('def test_pass(): pass') result, html = run(testdir) hash_key = ('test_extra_text_separated.py::' - 'test_pass00').encode('utf-8') + 'test_pass00') hash_generator = hashlib.md5() - hash_generator.update(hash_key) + hash_generator.update(hash_key.encode('utf-8')) assert result.ret == 0 - src = '{0}/{1}'.format('assets', '{0}.txt'. - format(hash_generator.hexdigest())) + src = '{0}/{1}'.format('assets', '{0}_{1}.txt'. + format(hash_key, hash_generator.hexdigest())) link = ('<a class="text" href="{0}" target="_blank">'.format(src)) assert link in html assert os.path.exists(src) @@ -412,13 +434,12 @@ """.format(extra_type, content)) testdir.makepyfile('def test_pass(): pass') result, html = run(testdir) - hash_key = ('test_extra_image_separated.py::' - 'test_pass00').encode('utf-8') + hash_key = 'test_extra_image_separated.py::test_pass00' hash_generator = hashlib.md5() - hash_generator.update(hash_key) + hash_generator.update(hash_key.encode('utf-8')) assert result.ret == 0 - src = '{0}/{1}'.format('assets', '{0}.{1}'. - format(hash_generator.hexdigest(), + src = '{0}/{1}'.format('assets', '{0}_{1}.{2}'. + format(hash_key, hash_generator.hexdigest(), file_extension)) link = ('<a class="image" href="{0}" target="_blank">'.format(src)) assert link in html @@ -451,11 +472,12 @@ for i in range(1, 4): hash_key = ('test_extra_image_separated_rerun.py::' - 'test_fail0{0}'.format(i)).encode('utf-8') + 'test_fail0{0}'.format(i)) hash_generator = hashlib.md5() - hash_generator.update(hash_key) - src = 'assets/{0}.{1}'.format(hash_generator.hexdigest(), - file_extension) + hash_generator.update(hash_key.encode('utf-8')) + src = 'assets/{0}_{1}.{2}'.format(hash_key, + hash_generator.hexdigest(), + file_extension) link = ('<a class="image" href="{0}" target="_blank">'.format(src)) assert result.ret assert link in html @@ -481,6 +503,35 @@ assert result.ret == 0 assert '<a href="{0}"><img src="{0}"/>'.format(content) in html + def test_very_long_test_name(self, testdir): + testdir.makeconftest(""" + import pytest + @pytest.mark.hookwrapper + def pytest_runtest_makereport(item, call): + outcome = yield + report = outcome.get_result() + if report.when == 'call': + from pytest_html import extras + report.extra = [extras.image('image.png')] + """) + # This will get truncated + test_name = 'test_{}'.format('a' * 300) + testdir.makepyfile(""" + def {0}(): + assert False + """.format(test_name)) + result, html = run(testdir) + + hash_key = 'test_very_long_test_name.py::{}00'.format(test_name) + hash_generator = hashlib.md5() + hash_generator.update(hash_key.encode('utf-8')) + src = 'assets/{0}_{1}.png'.format(hash_key[:218], + hash_generator.hexdigest()) + link = ('<a class="image" href="{0}" target="_blank">'.format(src)) + assert result.ret + assert link in html + assert os.path.exists(src) + def test_no_environment(self, testdir): testdir.makeconftest(""" def pytest_configure(config):