Skip to content

Commit 67bad95

Browse files
committed
Catch attribute exceptions
1 parent bb9813c commit 67bad95

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/test_formatter.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_minify():
7474

7575

7676
def test_exceptions():
77-
with pytest.raises(KeyError, match="Unknown option 'non_existent_option'"):
77+
with pytest.raises(AttributeError, match="Unknown option 'non_existent_option'"):
7878
_ = FracturedJsonOptions(non_existent_option=True)
7979

8080
with pytest.raises(
@@ -110,6 +110,19 @@ def test_exceptions():
110110
with pytest.raises(TypeError, match="Must be callable"):
111111
formatter.string_length_func = 123 # type: ignore[assignment]
112112

113+
options = FracturedJsonOptions()
114+
with pytest.raises(
115+
AttributeError,
116+
match="FracturedJsonOptions has no attribute 'invalid'",
117+
):
118+
_ = options.invalid
119+
120+
with pytest.raises(
121+
AttributeError,
122+
match="FracturedJsonOptions has no attribute 'invalid'",
123+
):
124+
options.invalid = 0
125+
113126

114127
def test_dll_missing(path_is_file_fails): # noqa: ARG001
115128
if "fractured_json" in sys.modules:

0 commit comments

Comments
 (0)