parent
b5f404bee7
commit
972058bb60
|
@ -24,3 +24,6 @@ local.properties
|
|||
|
||||
### YouCompleteMe - VIM plugin
|
||||
.ycm_extra_conf.py
|
||||
|
||||
##Tests JS
|
||||
node_modules/
|
||||
|
|
|
@ -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');
|
||||
};
|
|
@ -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
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>QUnit Pytest-HTML</title>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.0.1.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<script src="https://code.jquery.com/qunit/qunit-2.0.1.js"></script>
|
||||
<script src="https://raw.githubusercontent.com/alex-seville/blanket/master/dist/qunit/blanket.min.js"></script>
|
||||
<script src="test.js"></script>
|
||||
<script src="../pytest_html/resources/main.js" data-cover></script>
|
||||
<div id="qunit-fixture">
|
||||
<table id="results-table">
|
||||
<thead id="results-table-head">
|
||||
<tr>
|
||||
<th class="sortable result initial-sort" col="result">Result</th>
|
||||
<th class="sortable" col="name">Test</th>
|
||||
<th class="sortable numeric" col="duration">Duration</th>
|
||||
<th>Links</th></tr>
|
||||
<tr hidden="true" id="not-found-message">
|
||||
<th colspan="5">No results found. Try to check the filters</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="rerun results-table-row">
|
||||
<tr>
|
||||
<td class="col-result">Rerun</td>
|
||||
<td class="col-name">rerun.py::test_rexample</td>
|
||||
<td class="col-duration">1.00</td>
|
||||
<td class="col-links"></td></tr>
|
||||
<tr>
|
||||
<td class="extra" colspan="5">
|
||||
<div class="log">@pytest.mark.flaky(reruns=5)<br/> def test_example():<br/> import random<br/>> assert random.choice([True, False])<br/><span class="error">E assert False</span><br/><span class="error">E + where False = <bound method Random.choice of <random.Random object at 0x7fe80b85f420>>([True, False])</span><br/><span class="error">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</span><br/><br/>rerun.py:6: AssertionError<br/></div></td></tr></tbody>
|
||||
<tbody class="passed results-table-row">
|
||||
<tr>
|
||||
<td class="col-result">Passed</td>
|
||||
<td class="col-name">rerun.py::test_example</td>
|
||||
<td class="col-duration">0.00</td>
|
||||
<td class="col-links"></td></tr>
|
||||
<tr>
|
||||
<td class="extra" colspan="5">
|
||||
<div class="empty log">No log output captured.</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-result">Passed</td>
|
||||
<td class="col-name">rerun.py::test_example</td>
|
||||
<td class="col-duration">0.00</td>
|
||||
<td class="col-links"></td></tr>
|
||||
<tr>
|
||||
<td class="extra" colspan="5">
|
||||
<div class="empty log">No log output captured.</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,112 @@
|
|||
/* 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/. */
|
||||
|
||||
QUnit.module( 'module', {
|
||||
beforeEach: function( assert ) {
|
||||
init();
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test('sort_column', function(assert){
|
||||
function sort_column_test(col_re, first_element_then, first_element_now) {
|
||||
assert.equal(find_all('.results-table-row')[0].className, first_element_then);
|
||||
var row_sort = find(col_re);
|
||||
sort_column(row_sort);
|
||||
assert.equal(find_all('.results-table-row')[0].className, first_element_now);
|
||||
}
|
||||
//result
|
||||
sort_column_test('[col=result]',
|
||||
'rerun results-table-row', 'passed results-table-row');
|
||||
sort_column_test('[col=result]',
|
||||
'passed results-table-row', 'rerun results-table-row');
|
||||
|
||||
//name
|
||||
sort_column_test('[col=name]',
|
||||
'rerun results-table-row', 'passed results-table-row');
|
||||
sort_column_test('[col=name]',
|
||||
'passed results-table-row', 'rerun results-table-row');
|
||||
|
||||
//numeric
|
||||
sort_column_test('[col=duration]',
|
||||
'rerun results-table-row', 'passed results-table-row');
|
||||
sort_column_test('[col=duration]',
|
||||
'passed results-table-row', 'rerun results-table-row');
|
||||
});
|
||||
|
||||
QUnit.test('filter_table', function(assert){
|
||||
function filter_table_test(outcome, checked) {
|
||||
var filter_input = document.createElement('input');
|
||||
filter_input.setAttribute('data-test-result', outcome);
|
||||
filter_input.checked = checked;
|
||||
filter_table(filter_input);
|
||||
|
||||
var outcomes = find_all('.' + outcome);
|
||||
for(var i = 0; i < outcomes.length; i++) {
|
||||
assert.equal(outcomes[i].hidden, !checked);
|
||||
}
|
||||
}
|
||||
assert.equal(find('#not-found-message').hidden, true);
|
||||
|
||||
filter_table_test('rerun', false);
|
||||
filter_table_test('passed', false);
|
||||
assert.equal(find('#not-found-message').hidden, false);
|
||||
|
||||
filter_table_test('rerun', true);
|
||||
assert.equal(find('#not-found-message').hidden, true);
|
||||
|
||||
filter_table_test('passed', true);
|
||||
|
||||
});
|
||||
|
||||
QUnit.test('show_hide_extras', function(assert) {
|
||||
function show_extras_test(element){
|
||||
assert.equal(element.parentNode.nextElementSibling.className, 'collapsed');
|
||||
show_extras(element);
|
||||
assert.notEqual(element.parentNode.nextElementSibling.className, 'collapsed');
|
||||
}
|
||||
|
||||
function hide_extras_test(element){
|
||||
assert.notEqual(element.parentNode.nextElementSibling.className, 'collapsed');
|
||||
hide_extras(element);
|
||||
assert.equal(element.parentNode.nextElementSibling.className, 'collapsed');
|
||||
}
|
||||
//Passed results have log collapsed by default
|
||||
show_extras_test(find('.passed').firstElementChild.firstElementChild);
|
||||
hide_extras_test(find('.passed').firstElementChild.firstElementChild);
|
||||
|
||||
hide_extras_test(find('.rerun').firstElementChild.firstElementChild);
|
||||
show_extras_test(find('.rerun').firstElementChild.firstElementChild);
|
||||
});
|
||||
|
||||
QUnit.test('show_hide_all_extras', function(assert) {
|
||||
function show_all_extras_test(){
|
||||
show_all_extras();
|
||||
var extras = find_all('.extra');
|
||||
for (var i = 0; i < extras.length; i++) {
|
||||
assert.notEqual(extras[i].parentNode.className, 'collapsed');
|
||||
}
|
||||
}
|
||||
|
||||
function hide_all_extras_test(){
|
||||
hide_all_extras();
|
||||
var extras = find_all('.extra');
|
||||
for (var i = 0; i < extras.length; i++) {
|
||||
assert.equal(extras[i].parentNode.className, 'collapsed');
|
||||
}
|
||||
}
|
||||
|
||||
show_all_extras_test();
|
||||
hide_all_extras_test();
|
||||
});
|
||||
|
||||
QUnit.test('find', function (assert) {
|
||||
assert.notEqual(find('#results-table-head'), null);
|
||||
assert.notEqual(find('table#results-table'), null);
|
||||
assert.equal(find('.not-in-table'), null);
|
||||
});
|
||||
|
||||
QUnit.test('find_all', function(assert) {
|
||||
assert.equal(find_all('.sortable').length, 3);
|
||||
assert.equal(find_all('.not-in-table').length, 0);
|
||||
});
|
Loading…
Reference in New Issue