Skip to content

Commit 5bb22ff

Browse files
committed
Exclude abstract OCSP base class from test discovery
Use load_tests protocol to filter out _OCSPInteropBase which has CLIENT_BIN=None. Previously it showed as a confusing "binary not configured" skip.
1 parent 88127b9 commit 5bb22ff

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

tests/ocsp/ocsp-test.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ def _run_client(binary, port, extra_args=None):
108108

109109

110110
class _OCSPInteropBase(unittest.TestCase):
111-
"""Base class for a single client/responder combination."""
111+
"""Base class for a single client/responder combination.
112+
113+
Not intended to be run directly -- only concrete subclasses that
114+
set CLIENT_BIN and RESPONDER_BIN are meaningful test classes.
115+
"""
112116

113117
CLIENT_BIN = None
114118
RESPONDER_BIN = None
@@ -118,8 +122,6 @@ class _OCSPInteropBase(unittest.TestCase):
118122
def setUpClass(cls):
119123
if not os.path.isdir(CERTS_DIR):
120124
raise unittest.SkipTest("certs directory not found")
121-
if cls.CLIENT_BIN is None or cls.RESPONDER_BIN is None:
122-
raise unittest.SkipTest("binary not configured")
123125
if not _ocsp_supported(cls.CLIENT_BIN):
124126
raise unittest.SkipTest(f"OCSP not supported by {cls.CLIENT_BIN}")
125127
if not _ocsp_supported(cls.RESPONDER_BIN):
@@ -334,5 +336,15 @@ class TestOpensslClientOpensslResponder(_OCSPInteropBase):
334336
PORT = OCSP_PORT_BASE + 3
335337

336338

339+
def load_tests(loader, tests, pattern):
340+
"""Exclude the abstract _OCSPInteropBase from test discovery."""
341+
suite = unittest.TestSuite()
342+
for test_group in tests:
343+
for test in test_group:
344+
if type(test).mro()[0] is not _OCSPInteropBase:
345+
suite.addTest(test)
346+
return suite
347+
348+
337349
if __name__ == "__main__":
338350
test_main()

0 commit comments

Comments
 (0)