Skip to content

Commit

Permalink
Fixed pytest parameterization (#51)
Browse files Browse the repository at this point in the history
Very minor but it bothered me: the second list of parameters isn't actually a parameter, they don't have an effect on the results. They're simply different assertions and I don't think there's any reason to put them in separate tests.
  • Loading branch information
RobertoRoos committed May 3, 2024
1 parent eefe10b commit 699de12
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions test/test_default_html.py
Expand Up @@ -2,14 +2,15 @@

import pytest

from .conftest import check_xpath, flat_dict
from .conftest import check_xpath


@pytest.mark.parametrize(
"fname,expect",
flat_dict(
{
'index.html': [
"fname,expect_list",
[
(
'index.html',
[
(".//h1", 'Sample'),
(".//h1", 'blah-blah', False),
(".//div[@class='highlight']//span", 'usage'),
Expand All @@ -21,27 +22,34 @@
(".//section[@id='bar-options']", ''),
(".//section[@id='bar-options']/dl/dt[1]/kbd", '--bar'),
],
'subcommand-a.html': [
),
(
'subcommand-a.html',
[
(".//h1", 'Sample', False),
(".//h1", 'Command A'),
(".//div[@class='highlight']//span", 'usage'),
(".//h2", 'Positional Arguments'),
(".//section[@id='positional-arguments']", ''),
(".//section[@id='positional-arguments']/dl/dt[1]/kbd", 'baz'),
],
'special-characters.html': [
),
(
'special-characters.html',
[
(".//h1", 'Sample', False),
(".//h1", 'Special Characters'),
(".//section/dl/dd/p", 'Default:'),
(".//section/dl/dd/p/code/span", '420'),
(".//section/dl/dd/p/code/span", "'*.rst"),
(".//section/dl/dd/p/code/span", r"\['\*.rst',"),
],
}
),
),
],
)
@pytest.mark.sphinx('html', testroot='default-html')
def test_default_html(app, cached_etree_parse, fname, expect):
def test_default_html(app, cached_etree_parse, fname, expect_list):
app.build()
print(app.outdir / fname)
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)
for expect in expect_list:
check_xpath(cached_etree_parse(app.outdir / fname), fname, *expect)

0 comments on commit 699de12

Please sign in to comment.