Skip to content

Commit ccc4e7e

Browse files
committed
oscp linting
1 parent f845716 commit ccc4e7e

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

test/unit/test_ocsp.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,52 +81,54 @@ def overwrite_ocsp_cache(tmpdir):
8181
def worker_specific_cache_dir(tmpdir):
8282
"""Create worker-specific cache directory to avoid file lock conflicts in parallel execution."""
8383
import tempfile
84-
84+
8585
# Get worker ID for parallel execution (pytest-xdist)
86-
worker_id = os.environ.get('PYTEST_XDIST_WORKER', 'master')
87-
86+
worker_id = os.environ.get("PYTEST_XDIST_WORKER", "master")
87+
8888
# Create unique cache directory for this worker
8989
unique_cache_dir = tmpdir.join(f"ocsp_cache_{worker_id}")
9090
unique_cache_dir.mkdir()
91-
91+
9292
# Set environment variable to use worker-specific cache directory
9393
original_cache_dir = os.environ.get("SF_OCSP_RESPONSE_CACHE_DIR")
9494
os.environ["SF_OCSP_RESPONSE_CACHE_DIR"] = str(unique_cache_dir)
95-
95+
9696
# Reset cache to use new directory
9797
from snowflake.connector.ocsp_snowflake import OCSPCache
98+
9899
OCSPCache.reset_cache_dir()
99-
100+
100101
# Also handle the OCSP_RESPONSE_VALIDATION_CACHE to prevent conflicts
101102
try:
102103
from snowflake.connector.cache import SFDictFileCache
103104
import snowflake.connector.ocsp_snowflake as ocsp_module
104-
105+
105106
# Create worker-specific validation cache file
106107
validation_cache_file = tmpdir.join(f"ocsp_validation_cache_{worker_id}.json")
107-
108+
108109
# Create new cache instance for this worker
109110
worker_validation_cache = SFDictFileCache(
110-
file_path=str(validation_cache_file),
111-
entry_lifetime=3600
111+
file_path=str(validation_cache_file), entry_lifetime=3600
112112
)
113-
113+
114114
# Store original cache to restore later
115-
original_validation_cache = getattr(ocsp_module, 'OCSP_RESPONSE_VALIDATION_CACHE', None)
116-
115+
original_validation_cache = getattr(
116+
ocsp_module, "OCSP_RESPONSE_VALIDATION_CACHE", None
117+
)
118+
117119
# Replace with worker-specific cache
118120
ocsp_module.OCSP_RESPONSE_VALIDATION_CACHE = worker_validation_cache
119-
121+
120122
yield str(unique_cache_dir)
121-
123+
122124
# Restore original validation cache
123125
if original_validation_cache is not None:
124126
ocsp_module.OCSP_RESPONSE_VALIDATION_CACHE = original_validation_cache
125-
127+
126128
except ImportError:
127129
# If modules not available, just yield the directory
128130
yield str(unique_cache_dir)
129-
131+
130132
# Cleanup: restore original cache directory
131133
if original_cache_dir is not None:
132134
os.environ["SF_OCSP_RESPONSE_CACHE_DIR"] = original_cache_dir

0 commit comments

Comments
 (0)