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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != github.event.repository.default_branch }}
cancel-in-progress: ${{ ! contains(github.ref, github.event.repository.default_branch) }}

jobs:
build_docs:
Expand Down
2 changes: 1 addition & 1 deletion src/pytest_html/basereport.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def pytest_sessionstart(self, session):

header_cells = Header()
session.config.hook.pytest_html_results_table_header(cells=header_cells)

self._report.set_data("resultsTableHeader", header_cells.html)
self._report.set_data("headerPops", header_cells.get_pops())

self._report.set_data("runningState", "Started")
self._generate_report()
Expand Down
13 changes: 13 additions & 0 deletions src/pytest_html/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ const renderContent = (tests) => {
table.querySelectorAll('.extra').forEach((item) => {
item.colSpan = document.querySelectorAll('th').length
})

const { headerPops } = manager.renderData
if (headerPops > 0) {
// remove 'headerPops' number of header columns
findAll('#results-table-head th').splice(-headerPops).forEach(column => column.remove())

// remove 'headerPops' number of row columns
const resultRows = findAll('.results-table-row')
resultRows.forEach((elem) => {
findAll('td:not(.extra)', elem).splice(-headerPops).forEach(column => column.remove())
})
}

findAll('.sortable').forEach((elem) => {
elem.addEventListener('click', (evt) => {
const { target: element } = evt
Expand Down
1 change: 0 additions & 1 deletion src/pytest_html/scripts/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const doInitSort = () => {
const ascending = storageModule.getSortDirection()
const list = manager.testSubset
const initialOrder = ['Error', 'Failed', 'Rerun', 'XFailed', 'XPassed', 'Skipped', 'Passed']
console.log(list)
if (type?.toLowerCase() === 'original') {
manager.setRender(list)
} else {
Expand Down
13 changes: 9 additions & 4 deletions src/pytest_html/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Cell(Table):
def __init__(self):
super().__init__()
self._append_counter = 0
self._pop_counter = 0
self._sortables = dict()

def __setitem__(self, key, value):
Expand Down Expand Up @@ -69,10 +70,10 @@ def insert(self, index, html):
self._html[index] = html

def pop(self, *args):
warnings.warn(
"'pop' is deprecated and no longer supported.",
DeprecationWarning,
)
self._pop_counter += 1

def get_pops(self):
return self._pop_counter

def _extract_sortable(self, html):
match = re.search(r'<td class="col-(\w+)">(.*?)</', html)
Expand All @@ -90,3 +91,7 @@ class Row(Cell):
def __delitem__(self, key):
# This means the item should be removed
self._html = None

def pop(self, *args):
# Calling pop on header is sufficient
pass
21 changes: 21 additions & 0 deletions testing/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,27 @@ def test_pass(): pass
page = run(pytester)
assert_results(page, passed=1)

def test_results_table_hook_pop(self, pytester):
pytester.makeconftest(
"""
def pytest_html_results_table_header(cells):
cells.pop()

def pytest_html_results_table_row(report, cells):
cells.pop()
"""
)
pytester.makepyfile("def test_pass(): pass")
page = run(pytester)

header_columns = page.select(".summary #results-table-head th")
assert_that(header_columns).is_length(3)

row_columns = page.select_one(".summary .results-table-row").select(
"td:not(.extra)"
)
assert_that(row_columns).is_length(3)

@pytest.mark.parametrize("no_capture", ["", "-s"])
def test_standard_streams(self, pytester, no_capture):
pytester.makepyfile(
Expand Down
16 changes: 0 additions & 16 deletions testing/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,3 @@ def pytest_runtest_makereport(item, call):
"*DeprecationWarning: 'duration_formatter'*",
],
)


def test_cells_pop_deprecation_warning(pytester):
pytester.makeconftest(
"""
def pytest_html_results_table_row(cells):
cells.pop()
"""
)
pytester.makepyfile("def test_pass(): pass")
result = run(pytester)
result.stdout.fnmatch_lines(
[
"*DeprecationWarning: 'pop' is deprecated*",
],
)