-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_errors.py
More file actions
86 lines (61 loc) · 2 KB
/
Copy pathtest_errors.py
File metadata and controls
86 lines (61 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""Tests for AVP error types and hierarchy."""
from avp.errors import (
AVPError,
DecodeError,
EngineNotAvailableError,
HandshakeError,
IncompatibleModelsError,
InvalidMagicError,
RealignmentError,
SessionError,
SessionExpiredError,
ShapeMismatchError,
TransportError,
UnsupportedVersionError,
)
# --- Hierarchy ---
def test_all_errors_inherit_from_avp_error():
errors = [
InvalidMagicError(b"\x00\x00"),
UnsupportedVersionError(99),
DecodeError("bad"),
TransportError("fail", 500),
HandshakeError("no"),
SessionError("expired"),
SessionExpiredError("sess-1"),
ShapeMismatchError((10,), (20,)),
RealignmentError("oops"),
IncompatibleModelsError("mismatch"),
EngineNotAvailableError("vllm"),
]
for err in errors:
assert isinstance(err, AVPError)
def test_session_expired_is_session_error():
err = SessionExpiredError("s1")
assert isinstance(err, SessionError)
def test_incompatible_models_is_handshake_error():
err = IncompatibleModelsError("diff arch")
assert isinstance(err, HandshakeError)
# --- Error attributes ---
def test_invalid_magic_attributes():
err = InvalidMagicError(b"\xde\xad")
assert err.got == b"\xde\xad"
assert "dead" in str(err)
def test_unsupported_version_attributes():
err = UnsupportedVersionError(99)
assert err.version == 99
def test_transport_error_attributes():
err = TransportError("fail", status_code=503)
assert err.status_code == 503
def test_session_expired_attributes():
err = SessionExpiredError("sess-abc")
assert err.session_id == "sess-abc"
assert "sess-abc" in str(err)
def test_shape_mismatch_attributes():
err = ShapeMismatchError((10, 20), (10, 30))
assert err.expected == (10, 20)
assert err.got == (10, 30)
def test_engine_not_available_attributes():
err = EngineNotAvailableError("vllm")
assert err.engine == "vllm"
assert "vllm" in str(err)