diff --git a/.gitignore b/.gitignore index 7892b7d..7cf62bc 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ local.properties ### YouCompleteMe - VIM plugin .ycm_extra_conf.py + +##Tests JS +node_modules/ diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..19e5cf8 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,9 @@ +module.exports = function(grunt) { + grunt.initConfig({ + qunit: { + src: 'testing/js_test_report.html' + } + }); + grunt.loadNpmTasks('grunt-contrib-qunit'); + grunt.registerTask('test', 'qunit:src'); +}; diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..3c1140b --- /dev/null +++ b/circle.yml @@ -0,0 +1,11 @@ +## Customize dependencies +dependencies: + override: + - npm install -g grunt-cli + - npm install grunt + - npm install grunt-contrib-qunit + +## Customize test commands +test: + override: + - grunt test diff --git a/pytest_html/plugin.py b/pytest_html/plugin.py index 922c3ef..4977888 100644 --- a/pytest_html/plugin.py +++ b/pytest_html/plugin.py @@ -382,7 +382,8 @@ class HTMLReport(object): html.script(raw(main_js)), html.p('Report generated on {0} at {1}'.format( generated.strftime('%d-%b-%Y'), - generated.strftime('%H:%M:%S')))) + generated.strftime('%H:%M:%S'))), + onLoad='init()') if session.config._environment: environment = set(session.config._environment) diff --git a/pytest_html/resources/main.js b/pytest_html/resources/main.js index 64d325e..394b81e 100644 --- a/pytest_html/resources/main.js +++ b/pytest_html/resources/main.js @@ -97,7 +97,8 @@ function add_collapse() { }); }) } -addEventListener("DOMContentLoaded", function() { + +function init () { reset_sort_headers(); add_collapse(); @@ -113,7 +114,7 @@ addEventListener("DOMContentLoaded", function() { }, false) }); -}); +}; function sort_table(clicked, key_func) { var rows = find_all('.results-table-row'); @@ -207,8 +208,7 @@ function is_all_rows_hidden(value) { function filter_table(elem) { var outcome_att = "data-test-result"; var outcome = elem.getAttribute(outcome_att); - class_outcome = outcome + " results-table-row"; - var outcome_rows = document.getElementsByClassName(class_outcome); + var outcome_rows = find_all("." + outcome); for(var i = 0; i < outcome_rows.length; i++){ outcome_rows[i].hidden = !elem.checked; @@ -216,6 +216,5 @@ function filter_table(elem) { var rows = find_all('.results-table-row').filter(is_all_rows_hidden); var all_rows_hidden = rows.length == 0 ? true : false; - var not_found_message = document.getElementById("not-found-message"); - not_found_message.hidden = !all_rows_hidden; + find("#not-found-message").hidden = !all_rows_hidden; } diff --git a/testing/js_test_report.html b/testing/js_test_report.html new file mode 100644 index 0000000..2daebe6 --- /dev/null +++ b/testing/js_test_report.html @@ -0,0 +1,62 @@ + + +
+ + +Result | +Test | +Duration | +Links | |
---|---|---|---|---|
No results found. Try to check the filters | +||||
Rerun | +rerun.py::test_rexample | +1.00 | +||
+ @pytest.mark.flaky(reruns=5) def test_example(): import random > assert random.choice([True, False]) E assert False E + where False = <bound method Random.choice of <random.Random object at 0x7fe80b85f420>>([True, False]) E + where <bound method Random.choice of <random.Random object at 0x7fe80b85f420>> = <module 'random' from '/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.pyc'>.choice rerun.py:6: AssertionError | ||||
Passed | +rerun.py::test_example | +0.00 | +||
+ No log output captured.
+ |
+ ||||
Passed | +rerun.py::test_example | +0.00 | +||
+ No log output captured.
+ |
+