Skip to content

Commit 2c3086d

Browse files
committed
test(parameter): add unit test for addition of new attributes to parameter classes
1 parent d2c4e92 commit 2c3086d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_unittest.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
Unit tests
3+
"""
4+
5+
import pytest
6+
7+
from simulation.parameters import (
8+
ASUArrivals, RehabArrivals, ASULOS, RehabLOS,
9+
ASURouting, RehabRouting, Param)
10+
11+
12+
@pytest.mark.parametrize('class_to_test', [
13+
ASUArrivals, RehabArrivals, ASULOS, RehabLOS,
14+
ASURouting, RehabRouting, Param])
15+
def test_new_attribute(class_to_test):
16+
"""
17+
Confirm that it's impossible to add new attributes to the classes.
18+
19+
Arguments:
20+
class_to_test (class):
21+
The class to be tested for attribute immutability.
22+
"""
23+
# Create an instance of the class
24+
instance = class_to_test()
25+
26+
# Attempt to add a new attribute
27+
with pytest.raises(AttributeError,
28+
match='only possible to modify existing attributes'):
29+
setattr(instance, 'new_entry', 3)

0 commit comments

Comments
 (0)