Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
avoid rerunning test in refleak hunting mode.
  • Loading branch information
gpshead authored and xnox committed Sep 8, 2025
commit dabed52d66bfea3a89fe37ae741c2027b142c20a
5 changes: 5 additions & 0 deletions Lib/test/test_hashlib_fips.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@


class HashLibFIPSTestCase(unittest.TestCase):
_executions = 0 # prevent re-running on in refleak hunting mode, etc.

@classmethod
def setUpClass(cls):
if cls._executions > 0:
raise unittest.SkipTest("Cannot run this test within the same Python process.")
if sys.modules.get("_hashlib") or sys.modules.get("_ssl"):
raise AssertionError("_hashlib or _ssl already imported, too late to change OPENSSL_CONF.")
Comment thread
gpshead marked this conversation as resolved.
Outdated
# This openssl.cnf mocks FIPS mode without any digest
Expand Down Expand Up @@ -43,6 +47,7 @@ def tearDownClass(cls):
os.environ["OPENSSL_CONF"] = OPENSSL_CONF_BACKUP
else:
os.environ.pop("OPENSSL_CONF", None)
cls._executions += 1

def test_algorithms_available(self):
import hashlib
Expand Down