FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sdk-python/tests/strands/test_exception_notes.py at main · polytech-dev/sdk-python · GitHub
polytech-dev
/
sdk-python
Public
forked from
strands-agents/harness-sdk
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sdk-python
/
tests
/
strands
/
test_exception_notes.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (32 loc) · 1.85 KB
Breadcrumbs
sdk-python
/
tests
/
strands
/
test_exception_notes.py
Copy path
File metadata and controls
51 lines (32 loc) · 1.85 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
"""Tests for exception note utilities."""
import
sys
import
traceback
import
unittest
.
mock
import
pytest
from
strands
import
_exception_notes
from
strands
.
_exception_notes
import
add_exception_note
@
pytest
.
mark
.
skipif
(
sys
.
version_info
<
(
3
,
11
),
reason
=
"This test requires Python 3.11 or higher (need add_note)"
)
def
test_add_exception_note_python_311_plus
():
"""Test add_exception_note uses add_note in Python 3.11+."""
exception
=
ValueError
(
"original message"
)
add_exception_note
(
exception
,
"test note"
)
assert
traceback
.
format_exception
(
exception
)
==
[
"ValueError: original message
\n
"
,
"test note
\n
"
]
def
test_add_exception_note_python_310
():
"""Test add_exception_note modifies args in Python 3.10."""
with
unittest
.
mock
.
patch
.
object
(
_exception_notes
,
"supports_add_note"
,
False
):
exception
=
ValueError
(
"original message"
)
add_exception_note
(
exception
,
"test note"
)
assert
traceback
.
format_exception
(
exception
)
==
[
"ValueError: original message
\n
test note
\n
"
]
def
test_add_exception_note_python_310_no_args
():
"""Test add_exception_note handles exception with no args in Python 3.10."""
with
unittest
.
mock
.
patch
.
object
(
_exception_notes
,
"supports_add_note"
,
False
):
exception
=
ValueError
()
exception
.
args
=
()
add_exception_note
(
exception
,
"test note"
)
assert
traceback
.
format_exception
(
exception
)
==
[
"ValueError: test note
\n
"
]
def
test_add_exception_note_python_310_multiple_args
():
"""Test add_exception_note preserves additional args in Python 3.10."""
with
unittest
.
mock
.
patch
.
object
(
_exception_notes
,
"supports_add_note"
,
False
):
exception
=
ValueError
(
"original message"
,
"second arg"
)
add_exception_note
(
exception
,
"test note"
)
assert
traceback
.
format_exception
(
exception
)
==
[
"ValueError: ('original message
\\
ntest note', 'second arg')
\n
"
]
Back
|
FazBrowse Home
|
New Git URL