Skip to content

Commit 0dbef0d

Browse files
committed
avoid rerunning test in refleak hunting mode.
1 parent f8c5133 commit 0dbef0d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/test/test_hashlib_fips.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212

1313

1414
class HashLibFIPSTestCase(unittest.TestCase):
15+
_executions = 0 # prevent re-running on in refleak hunting mode, etc.
16+
1517
@classmethod
1618
def setUpClass(cls):
19+
if cls._executions > 0:
20+
raise unittest.SkipTest("Cannot run this test within the same Python process.")
1721
if sys.modules.get("_hashlib") or sys.modules.get("_ssl"):
1822
raise AssertionError("_hashlib or _ssl already imported, too late to change OPENSSL_CONF.")
1923
# This openssl.cnf mocks FIPS mode without any digest
@@ -43,6 +47,7 @@ def tearDownClass(cls):
4347
os.environ["OPENSSL_CONF"] = OPENSSL_CONF_BACKUP
4448
else:
4549
os.environ.pop("OPENSSL_CONF", None)
50+
cls._executions += 1
4651

4752
def test_algorithms_available(self):
4853
import hashlib

0 commit comments

Comments
 (0)