[Bugfix]: During testing, use pytest monkeypatch for safely overriding the env var that indicates the vLLM backend (#5210)
This commit is contained in:
22
tests/kernels/utils.py
Normal file
22
tests/kernels/utils.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""Kernel test utils"""
|
||||
|
||||
import pytest
|
||||
|
||||
STR_BACKEND_ENV_VAR: str = "VLLM_ATTENTION_BACKEND"
|
||||
STR_FLASH_ATTN_VAL: str = "FLASH_ATTN"
|
||||
STR_INVALID_VAL: str = "INVALID"
|
||||
|
||||
|
||||
def override_backend_env_variable(mpatch: pytest.MonkeyPatch,
|
||||
backend_name: str) -> None:
|
||||
'''
|
||||
Override the environment variable indicating the vLLM backend temporarily,
|
||||
using pytest monkeypatch to ensure that the env vars get
|
||||
reset once the test context exits.
|
||||
|
||||
Arguments:
|
||||
|
||||
* mpatch: pytest monkeypatch instance
|
||||
* backend_name: attention backend name to force
|
||||
'''
|
||||
mpatch.setenv(STR_BACKEND_ENV_VAR, backend_name)
|
||||
Reference in New Issue
Block a user