Fix certbot tests after updating pytest to 9.0.2 (#10545)

Fixes  #10518.

`tools/pinning/current/repin.sh` is not run; only pytest version is
updated. This is because `pypinning` had a bunch of syntax changes that
seem simply but I believe should be in a separate PR, which I think
should be done after this to collect all repin changes.

As discussed further in #10518, these issues were caused by pytest's
internalization of pytest-subtest, which had several implementation
changes.

To fix these, we simply no longer use subtest in the failing tests. The
test in acme is now parametrized instead, and the tests in apache only
ever had a single parameter.

To use parametrization in the acme test, I converted `DNSTest` from
unittest to pytest style, which was pretty straightforward. The only
note there is that while it would be nice to make `ec_secp384r1_key` a
fixture, you [can't use fixtures in
parameters](https://github.com/pytest-dev/pytest/issues/349). You could
use requests, but that seemed less clear and messier, because then you'd
be checking the value of the parameter and only sometimes loading it.
Could also make it a global variable, but that didn't really seem
necessary, as it's only called twice. Happy to consider other options,
not strongly tied to this one, just seemed nicest to me.
This commit is contained in:
ohemorange
2026-02-02 12:13:24 -08:00
committed by GitHub
parent 88af129315
commit b362109bf6
3 changed files with 55 additions and 43 deletions
@@ -337,10 +337,10 @@ class DualParserNodeTest(unittest.TestCase): # pylint: disable=too-many-public-
self.block.secondary.find_blocks = find_blocks_secondary
blocks = self.block.find_blocks("anything")
assert len(blocks) == 1
for block in blocks:
with self.subTest(block=block):
assert block.primary == block.secondary
assert block.primary is not block.secondary
assert block.primary == block.secondary
assert block.primary is not block.secondary
def test_find_dirs_no_pass_equal(self):
notpassing1 = [augeasparser.AugeasDirectiveNode(name="notpassing",
@@ -357,10 +357,10 @@ class DualParserNodeTest(unittest.TestCase): # pylint: disable=too-many-public-
self.block.secondary.find_directives = find_dirs_secondary
directives = self.block.find_directives("anything")
assert len(directives) == 1
for directive in directives:
with self.subTest(directive=directive):
assert directive.primary == directive.secondary
assert directive.primary is not directive.secondary
assert directive.primary == directive.secondary
assert directive.primary is not directive.secondary
def test_find_comments_no_pass_equal(self):
notpassing1 = [augeasparser.AugeasCommentNode(comment="notpassing",
@@ -377,10 +377,10 @@ class DualParserNodeTest(unittest.TestCase): # pylint: disable=too-many-public-
self.block.secondary.find_comments = find_coms_secondary
comments = self.block.find_comments("anything")
assert len(comments) == 1
for comment in comments:
with self.subTest(comment=comment):
assert comment.primary == comment.secondary
assert comment.primary is not comment.secondary
assert comment.primary == comment.secondary
assert comment.primary is not comment.secondary
def test_find_blocks_no_pass_notequal(self):
notpassing1 = [augeasparser.AugeasBlockNode(name="notpassing",