Skip to content

Commit 1527bd1

Browse files
committed
test(lockeddict): add lockeddict test checking that dot-notation raises an error
1 parent 4582ada commit 1527bd1

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/test_unittest.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import pytest
1616
from sim_tools.distributions import Exponential, Lognormal, DiscreteEmpirical
1717

18-
from simulation import Model, Param, Runner, SimLogger
18+
from simulation import LockedDict, Model, Param, Runner, SimLogger
1919

2020

2121
# -----------------------------------------------------------------------------
@@ -247,3 +247,19 @@ def test_invalid_file_extension():
247247
"""
248248
with pytest.raises(ValueError):
249249
SimLogger(log_to_file=True, file_path="test.txt")
250+
251+
252+
# -----------------------------------------------------------------------------
253+
# LockedDict
254+
# -----------------------------------------------------------------------------
255+
256+
def test_lockeddict_attribute():
257+
"""
258+
Setting a value using dot-notation should fail and raise an error.
259+
"""
260+
ld = LockedDict({"a": 1, "b": 2})
261+
262+
with pytest.raises(AttributeError) as e:
263+
ld.a = 99
264+
265+
assert "Cannot set attribute" in str(e) and "Use item syntax" in str(e)

0 commit comments

Comments
 (0)