@@ -1890,7 +1890,7 @@ def test_dictionary_accessors(self):
18901890 name = "fresh_one" , type = "Structure"
18911891 )
18921892 # rule must be Rule object
1893- with self .assertRaisesRegex (TypeError , "'rule'.*Rule " ):
1893+ with self .assertRaisesRegex (TypeError , "'rule'.*'str' " ):
18941894 dictionary .add_variable_from_spec (
18951895 name = "fresh_one" , type = "Categorical" , rule = {}
18961896 )
@@ -1904,7 +1904,9 @@ def test_dictionary_accessors(self):
19041904 name = "fresh_one" ,
19051905 type = "Categorical" ,
19061906 meta_data = {"a" : 1 , "b" : 2 },
1907- rule = kh .Rule ("Ceil" , kh .Rule ("Product" , 3 , kh .Rule ("Random()" ))),
1907+ rule = str (
1908+ kh .Rule ("Ceil" , kh .Rule ("Product" , 3 , kh .Rule ("Random()" )))
1909+ ),
19081910 )
19091911 self .assertEqual (
19101912 2 ,
@@ -1913,7 +1915,7 @@ def test_dictionary_accessors(self):
19131915 )
19141916 self .assertEqual (
19151917 "Ceil(Product(3, Random()))" ,
1916- repr ( dictionary .get_variable ("fresh_one" ).get_rule ()) ,
1918+ dictionary .get_variable ("fresh_one" ).rule ,
19171919 "Variable rule must be set correctly" ,
19181920 )
19191921 variable_rule = kh .Rule (verbatim = "Ceil(Product(3, Random()))" )
@@ -1965,7 +1967,7 @@ def test_dictionary_accessors(self):
19651967 block_rule = kh .Rule ("SomeBlockCreatingRule" )
19661968 with self .assertRaises (TypeError ):
19671969 dictionary_copy .get_variable_block (block .name ).rule = block_rule
1968- dictionary_copy .get_variable_block (block .name ).set_rule (block_rule )
1970+ dictionary_copy .get_variable_block (block .name ).rule = str (block_rule )
19691971 self .assertEqual (block , dictionary_copy .get_variable_block (block .name ))
19701972 removed_block = dictionary_copy .remove_variable_block (
19711973 block .name ,
@@ -2020,13 +2022,13 @@ def test_dictionary_accessors(self):
20202022 2 ,
20212023 kh .Rule ("SomeEmbeddedRule()" ),
20222024 )
2023- dictionary_copy .get_variable (variable_name ).set_rule (some_rule )
2025+ dictionary_copy .get_variable (variable_name ).rule = str (some_rule )
20242026 self .assertEqual (
20252027 dictionary_copy .get_variable (variable_name ).rule ,
20262028 repr (some_rule ),
20272029 )
20282030 self .assertEqual (
2029- repr ( dictionary_copy .get_variable (variable_name ).get_rule ()) ,
2031+ dictionary_copy .get_variable (variable_name ).rule ,
20302032 repr (some_rule ),
20312033 )
20322034 some_reference_rule = kh .Rule (
@@ -2039,15 +2041,15 @@ def test_dictionary_accessors(self):
20392041 ),
20402042 is_reference = True ,
20412043 )
2042- dictionary_copy .get_variable (variable_name ).set_rule (
2044+ dictionary_copy .get_variable (variable_name ).rule = str (
20432045 some_reference_rule
20442046 )
20452047 self .assertEqual (
20462048 dictionary_copy .get_variable (variable_name ).rule ,
20472049 repr (some_reference_rule ),
20482050 )
20492051 self .assertEqual (
2050- repr ( dictionary_copy .get_variable (variable_name ).get_rule ()) ,
2052+ dictionary_copy .get_variable (variable_name ).rule ,
20512053 repr (some_reference_rule ),
20522054 )
20532055 for variable_block_index , variable_block_name in enumerate (
@@ -2062,31 +2064,21 @@ def test_dictionary_accessors(self):
20622064 2 ,
20632065 kh .Rule ("SomeEmbeddedRule()" ),
20642066 )
2065- dictionary_copy .get_variable_block (variable_block_name ).set_rule (
2067+ dictionary_copy .get_variable_block (variable_block_name ).rule = str (
20662068 some_rule
20672069 )
20682070 self .assertEqual (
20692071 dictionary_copy .get_variable_block (variable_block_name ).rule ,
20702072 repr (some_rule ),
20712073 )
20722074 self .assertEqual (
2073- repr (
2074- dictionary_copy .get_variable_block (
2075- variable_block_name
2076- ).get_rule ()
2077- ),
2075+ dictionary_copy .get_variable_block (variable_block_name ).rule ,
20782076 repr (some_rule ),
20792077 )
2080- some_reference_rule = kh .Rule (
2081- "some_reference_operand_for_variable block"
2082- + variable_block_index * "i" ,
2083- 3 ,
2084- is_reference = True ,
2085- )
2086- with self .assertRaises (ValueError ):
2087- dictionary_copy .get_variable_block (
2088- variable_block_name
2089- ).set_rule (some_reference_rule )
2078+ with self .assertRaises (TypeError ):
2079+ dictionary_copy .get_variable_block (variable_block_name ).rule = (
2080+ some_rule
2081+ )
20902082
20912083 def test_dictionary_rule_construction (self ):
20922084 """Tests the Rule construction and serialization"""
0 commit comments