11import pytest
22
33from ..state import State
4+ from ..helpers_state import PydraStateError
45
56
67@pytest .mark .parametrize (
@@ -95,27 +96,27 @@ def test_state_1(
9596
9697
9798def test_state_2_err ():
98- with pytest .raises (Exception ) as exinfo :
99+ with pytest .raises (PydraStateError ) as exinfo :
99100 st = State ("NA" , splitter = {"a" })
100101 assert "splitter has to be a string, a tuple or a list" == str (exinfo .value )
101102
102103
103104def test_state_3_err ():
104- with pytest .raises (Exception ) as exinfo :
105+ with pytest .raises (PydraStateError ) as exinfo :
105106 st = State ("NA" , splitter = ["a" , "b" ], combiner = ("a" , "b" ))
106107 assert "combiner has to be a string or a list" == str (exinfo .value )
107108
108109
109110def test_state_4_err ():
110111 st = State ("NA" , splitter = "a" , combiner = ["a" , "b" ])
111- with pytest .raises (Exception ) as exinfo :
112+ with pytest .raises (PydraStateError ) as exinfo :
112113 st .combiner_validation ()
113114 assert "all combiners have to be in the splitter" in str (exinfo .value )
114115
115116
116117def test_state_5_err ():
117118 st = State ("NA" , combiner = "a" )
118- with pytest .raises (Exception ) as exinfo :
119+ with pytest .raises (PydraStateError ) as exinfo :
119120 st .combiner_validation ()
120121 assert "splitter has to be set before" in str (exinfo .value )
121122
@@ -166,7 +167,7 @@ def test_state_connect_1b_exception():
166167 """can't provide explicitly NA.a (should be _NA)"""
167168 st1 = State (name = "NA" , splitter = "a" , other_states = {})
168169 st2 = State (name = "NB" , splitter = "NA.a" )
169- with pytest .raises (Exception ) as excinfo :
170+ with pytest .raises (PydraStateError ) as excinfo :
170171 st2 .splitter_validation ()
171172 assert "consider using _NA" in str (excinfo .value )
172173
@@ -175,7 +176,7 @@ def test_state_connect_1b_exception():
175176def test_state_connect_1c_exception (splitter2 , other_states2 ):
176177 """can't ask for splitter from node that is not connected"""
177178 st1 = State (name = "NA" , splitter = "a" )
178- with pytest .raises (Exception ) as excinfo :
179+ with pytest .raises (PydraStateError ) as excinfo :
179180 st2 = State (name = "NB" , splitter = splitter2 , other_states = other_states2 )
180181 st2 .splitter_validation ()
181182
@@ -691,7 +692,7 @@ def test_state_connect_innerspl_1a():
691692
692693def test_state_connect_innerspl_1b ():
693694 """incorrect splitter - Right & Left parts in scalar splitter"""
694- with pytest .raises (Exception ):
695+ with pytest .raises (PydraStateError ):
695696 st1 = State (name = "NA" , splitter = "a" )
696697 st2 = State (name = "NB" , splitter = ("_NA" , "b" ), other_states = {"NA" : (st1 , "b" )})
697698
@@ -1718,7 +1719,7 @@ def test_connect_splitters(
17181719 ],
17191720)
17201721def test_connect_splitters_exception_1 (splitter , other_states ):
1721- with pytest .raises (Exception ) as excinfo :
1722+ with pytest .raises (PydraStateError ) as excinfo :
17221723 st = State (name = "CN" , splitter = splitter , other_states = other_states )
17231724 assert "Left and Right splitters are mixed" in str (excinfo .value )
17241725
@@ -1729,13 +1730,13 @@ def test_connect_splitters_exception_2():
17291730 splitter = "_NB" ,
17301731 other_states = {"NA" : (State (name = "NA" , splitter = "a" ), "b" )},
17311732 )
1732- with pytest .raises (Exception ) as excinfo :
1733+ with pytest .raises (PydraStateError ) as excinfo :
17331734 st .set_input_groups ()
17341735 assert "can't ask for splitter from NB" in str (excinfo .value )
17351736
17361737
17371738def test_connect_splitters_exception_3 ():
1738- with pytest .raises (Exception ) as excinfo :
1739+ with pytest .raises (PydraStateError ) as excinfo :
17391740 st = State (
17401741 name = "CN" ,
17411742 splitter = "_NB" ,
0 commit comments