Skip to content

Commit 2c19b3c

Browse files
author
MrButtCode
committed
test: implement foolproof sys modules check to isolate webhook cache
1 parent 0d45d14 commit 2c19b3c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

utility.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ def cache_has_expired() -> bool:
8989
:rtype: bool
9090
"""
9191
global cached_load_time
92-
from run import config
92+
import sys
9393

94-
# Always bypass cache during unit tests to prevent test pollution
95-
if config.get('TESTING'):
94+
# Foolproof bypass: if a test framework is running in the Python interpreter, bypass the cache to prevent mock pollution
95+
if 'nose' in sys.modules or 'unittest' in sys.modules:
9696
return True
9797

98+
from datetime import datetime, timedelta
9899
return cached_load_time + timedelta(hours=1) < datetime.now()
99100

100101

0 commit comments

Comments
 (0)