Fix Test* mixin classes being collected as standalone pytest tests (#20417)

This commit is contained in:
Pai Liu
2026-03-12 18:18:45 -07:00
committed by GitHub
parent 9865f11421
commit 65dd08153d
9 changed files with 45 additions and 41 deletions
@@ -3,7 +3,8 @@ import json
import requests import requests
class TestEBNFConstrainedMixin: class EBNFConstrainedMixin:
ebnf_grammar = 'root ::= "test"' # Default grammar ebnf_grammar = 'root ::= "test"' # Default grammar
def _run_decode_ebnf( def _run_decode_ebnf(
@@ -5,7 +5,8 @@ import openai
import requests import requests
class TestJSONConstrainedMixin: class JSONConstrainedMixin:
json_schema = json.dumps( json_schema = json.dumps(
{ {
"type": "object", "type": "object",
@@ -3,7 +3,8 @@ import json
import requests import requests
class TestRegexConstrainedMixin: class RegexConstrainedMixin:
def _run_decode_regex( def _run_decode_regex(
self, self,
regex, regex,
+1
View File
@@ -2056,6 +2056,7 @@ def _distributed_worker(rank, world_size, backend, port, func, result_queue, kwa
class CustomTestCase(unittest.TestCase): class CustomTestCase(unittest.TestCase):
def _callTestMethod(self, method): def _callTestMethod(self, method):
max_retry = envs.SGLANG_TEST_MAX_RETRY.get() max_retry = envs.SGLANG_TEST_MAX_RETRY.get()
if max_retry is None: if max_retry is None:
@@ -2,9 +2,9 @@ import unittest
from sglang.srt.utils import kill_process_tree from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.kits.ebnf_constrained_kit import TestEBNFConstrainedMixin from sglang.test.kits.ebnf_constrained_kit import EBNFConstrainedMixin
from sglang.test.kits.json_constrained_kit import TestJSONConstrainedMixin from sglang.test.kits.json_constrained_kit import JSONConstrainedMixin
from sglang.test.kits.regex_constrained_kit import TestRegexConstrainedMixin from sglang.test.kits.regex_constrained_kit import RegexConstrainedMixin
from sglang.test.test_utils import ( from sglang.test.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST, DEFAULT_SMALL_MODEL_NAME_FOR_TEST,
DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
@@ -49,22 +49,22 @@ class ServerWithGrammar(CustomTestCase):
class TestXGrammarBackend( class TestXGrammarBackend(
ServerWithGrammar, ServerWithGrammar,
TestJSONConstrainedMixin, JSONConstrainedMixin,
TestEBNFConstrainedMixin, EBNFConstrainedMixin,
TestRegexConstrainedMixin, RegexConstrainedMixin,
): ):
backend = "xgrammar" backend = "xgrammar"
class TestOutlinesBackend(ServerWithGrammar, TestJSONConstrainedMixin): class TestOutlinesBackend(ServerWithGrammar, JSONConstrainedMixin):
backend = "outlines" backend = "outlines"
class TestLLGuidanceBackend( class TestLLGuidanceBackend(
ServerWithGrammar, ServerWithGrammar,
TestJSONConstrainedMixin, JSONConstrainedMixin,
TestEBNFConstrainedMixin, EBNFConstrainedMixin,
TestRegexConstrainedMixin, RegexConstrainedMixin,
): ):
backend = "llguidance" backend = "llguidance"
@@ -8,10 +8,10 @@ from sglang.srt.environ import envs
from sglang.srt.utils import kill_process_tree from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k
from sglang.test.kits.ebnf_constrained_kit import TestEBNFConstrainedMixin from sglang.test.kits.ebnf_constrained_kit import EBNFConstrainedMixin
from sglang.test.kits.json_constrained_kit import TestJSONConstrainedMixin from sglang.test.kits.json_constrained_kit import JSONConstrainedMixin
from sglang.test.kits.radix_cache_server_kit import run_radix_attention_test from sglang.test.kits.radix_cache_server_kit import run_radix_attention_test
from sglang.test.kits.regex_constrained_kit import TestRegexConstrainedMixin from sglang.test.kits.regex_constrained_kit import RegexConstrainedMixin
from sglang.test.run_eval import run_eval from sglang.test.run_eval import run_eval
from sglang.test.test_utils import ( from sglang.test.test_utils import (
DEFAULT_IMAGE_URL, DEFAULT_IMAGE_URL,
@@ -30,9 +30,9 @@ register_cuda_ci(est_time=350, suite="stage-b-test-large-2-gpu")
class TestDPAttentionDP2TP2( class TestDPAttentionDP2TP2(
CustomTestCase, CustomTestCase,
TestJSONConstrainedMixin, JSONConstrainedMixin,
TestEBNFConstrainedMixin, EBNFConstrainedMixin,
TestRegexConstrainedMixin, RegexConstrainedMixin,
): ):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -75,9 +75,9 @@ class TestDPAttentionDP2TP2(
class TestDPRetract( class TestDPRetract(
CustomTestCase, CustomTestCase,
TestJSONConstrainedMixin, JSONConstrainedMixin,
TestEBNFConstrainedMixin, EBNFConstrainedMixin,
TestRegexConstrainedMixin, RegexConstrainedMixin,
): ):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -115,9 +115,9 @@ class TestDPRetract(
class TestDPAttentionDP2TP2DeepseekV3MTP( class TestDPAttentionDP2TP2DeepseekV3MTP(
CustomTestCase, CustomTestCase,
TestJSONConstrainedMixin, JSONConstrainedMixin,
TestEBNFConstrainedMixin, EBNFConstrainedMixin,
TestRegexConstrainedMixin, RegexConstrainedMixin,
): ):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -7,9 +7,9 @@ from sglang.lang.chat_template import get_chat_template_by_model_path
from sglang.srt.utils import kill_process_tree from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k
from sglang.test.kits.ebnf_constrained_kit import TestEBNFConstrainedMixin from sglang.test.kits.ebnf_constrained_kit import EBNFConstrainedMixin
from sglang.test.kits.json_constrained_kit import TestJSONConstrainedMixin from sglang.test.kits.json_constrained_kit import JSONConstrainedMixin
from sglang.test.kits.regex_constrained_kit import TestRegexConstrainedMixin from sglang.test.kits.regex_constrained_kit import RegexConstrainedMixin
from sglang.test.run_eval import run_eval from sglang.test.run_eval import run_eval
from sglang.test.test_utils import ( from sglang.test.test_utils import (
DEFAULT_IMAGE_URL, DEFAULT_IMAGE_URL,
@@ -28,9 +28,9 @@ register_cuda_ci(est_time=350, suite="stage-c-test-4-gpu-h100")
class TestDPAttentionDP2TP4( class TestDPAttentionDP2TP4(
CustomTestCase, CustomTestCase,
TestJSONConstrainedMixin, JSONConstrainedMixin,
TestEBNFConstrainedMixin, EBNFConstrainedMixin,
TestRegexConstrainedMixin, RegexConstrainedMixin,
): ):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -68,9 +68,9 @@ class TestDPAttentionDP2TP4(
class TestDPAttentionDP2TP2DeepseekV3MTP( class TestDPAttentionDP2TP2DeepseekV3MTP(
CustomTestCase, CustomTestCase,
TestJSONConstrainedMixin, JSONConstrainedMixin,
TestEBNFConstrainedMixin, EBNFConstrainedMixin,
TestRegexConstrainedMixin, RegexConstrainedMixin,
): ):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
@@ -18,7 +18,7 @@ register_cuda_ci(est_time=109, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=180, suite="stage-b-test-small-1-gpu-amd") register_amd_ci(est_time=180, suite="stage-b-test-small-1-gpu-amd")
class TestJSONModeMixin: class JSONModeMixin:
"""Mixin class containing JSON mode test methods""" """Mixin class containing JSON mode test methods"""
def test_json_mode_response(self): def test_json_mode_response(self):
@@ -123,15 +123,15 @@ class ServerWithGrammarBackend(CustomTestCase):
kill_process_tree(cls.process.pid) kill_process_tree(cls.process.pid)
class TestJSONModeXGrammar(ServerWithGrammarBackend, TestJSONModeMixin): class TestJSONModeXGrammar(ServerWithGrammarBackend, JSONModeMixin):
backend = "xgrammar" backend = "xgrammar"
class TestJSONModeOutlines(ServerWithGrammarBackend, TestJSONModeMixin): class TestJSONModeOutlines(ServerWithGrammarBackend, JSONModeMixin):
backend = "outlines" backend = "outlines"
class TestJSONModeLLGuidance(ServerWithGrammarBackend, TestJSONModeMixin): class TestJSONModeLLGuidance(ServerWithGrammarBackend, JSONModeMixin):
backend = "llguidance" backend = "llguidance"
@@ -3,8 +3,8 @@ import unittest
from sglang.srt.environ import envs from sglang.srt.environ import envs
from sglang.srt.utils import kill_process_tree from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.kits.json_constrained_kit import TestJSONConstrainedMixin from sglang.test.kits.json_constrained_kit import JSONConstrainedMixin
from sglang.test.kits.regex_constrained_kit import TestRegexConstrainedMixin from sglang.test.kits.regex_constrained_kit import RegexConstrainedMixin
from sglang.test.test_utils import ( from sglang.test.test_utils import (
DEFAULT_DRAFT_MODEL_EAGLE, DEFAULT_DRAFT_MODEL_EAGLE,
DEFAULT_TARGET_MODEL_EAGLE, DEFAULT_TARGET_MODEL_EAGLE,
@@ -18,7 +18,7 @@ register_cuda_ci(est_time=100, suite="stage-b-test-large-1-gpu")
class TestEagleConstrainedDecoding( class TestEagleConstrainedDecoding(
CustomTestCase, TestRegexConstrainedMixin, TestJSONConstrainedMixin CustomTestCase, RegexConstrainedMixin, JSONConstrainedMixin
): ):
max_running_requests = 64 max_running_requests = 64
attention_backend = "triton" attention_backend = "triton"