@@ -930,7 +930,7 @@ def test_value_none_rejected_set_after_init(self, record_funcs_reject_none):
930930 process .terminate ()
931931 process .join (timeout = 3 )
932932
933- def fixture_names (params ):
933+ def validate_fixture_names (params ):
934934 """Provide nice names for the out_records fixture in TestValidate class"""
935935 return params [0 ].__name__
936936class TestValidate :
@@ -947,7 +947,7 @@ class TestValidate:
947947 (builder .WaveformOut , [10 , 11 , 12 ], []),
948948 (builder .longStringOut , "A LONGER HELLO" , "" ),
949949 ],
950- ids = fixture_names
950+ ids = validate_fixture_names
951951 )
952952 def out_records (self , request ):
953953 """The list of Out records and an associated value to set """
@@ -992,18 +992,17 @@ def validate_ioc_test_func(self, record_func, queue, validate_pass: bool):
992992 asyncio .sleep (TIMEOUT ), dispatcher .loop
993993 ).result ()
994994
995-
996- @requires_cothread
997- def test_validate_allows_updates (self , out_records ):
998- """Test that record values are updated correctly when validate
999- method allows it """
1000-
1001- creation_func , value , _ = out_records
995+ def validate_test_runner (
996+ self ,
997+ creation_func ,
998+ new_value ,
999+ expected_value ,
1000+ validate_pass : bool ):
10021001
10031002 queue = multiprocessing .Queue ()
10041003 process = multiprocessing .Process (
10051004 target = self .validate_ioc_test_func ,
1006- args = (creation_func , queue , True ),
1005+ args = (creation_func , queue , validate_pass ),
10071006 )
10081007
10091008 process .start ()
@@ -1018,7 +1017,7 @@ def test_validate_allows_updates(self, out_records):
10181017
10191018 put_ret = caput (
10201019 DEVICE_NAME + ":" + "VALIDATE-RECORD" ,
1021- value ,
1020+ new_value ,
10221021 wait = True ,
10231022 )
10241023 assert put_ret .ok , "caput did not succeed"
@@ -1029,54 +1028,30 @@ def test_validate_allows_updates(self, out_records):
10291028 )
10301029
10311030 if creation_func in [builder .WaveformOut , builder .WaveformIn ]:
1032- assert numpy .array_equal (ret_val , value )
1031+ assert numpy .array_equal (ret_val , expected_value )
10331032 else :
1034- assert ret_val == value
1033+ assert ret_val == expected_value
10351034
10361035 finally :
10371036 process .terminate ()
10381037 process .join (timeout = 3 )
10391038
1040- @requires_cothread
1041- def test_validate_blocks_updates (self , out_records ):
1042- """Test that record values are not updated when validate method
1043- always blocks updates"""
10441039
1045- creation_func , value , default = out_records
1046-
1047- queue = multiprocessing .Queue ()
1048- process = multiprocessing .Process (
1049- target = self .validate_ioc_test_func ,
1050- args = (creation_func , queue , False ),
1051- )
1052-
1053- process .start ()
1054-
1055- try :
1056- queue .get (timeout = 5 ) # Get the expected IOC initialised message
1040+ @requires_cothread
1041+ def test_validate_allows_updates (self , out_records ):
1042+ """Test that record values are updated correctly when validate
1043+ method allows it """
10571044
1058- from cothread . catools import caget , caput , _channel_cache
1045+ creation_func , value , _ = out_records
10591046
1060- # See other places in this file for why we call it
1061- _channel_cache .purge ()
1047+ self .validate_test_runner (creation_func , value , value , True )
10621048
1063- put_ret = caput (
1064- DEVICE_NAME + ":" + "VALIDATE-RECORD" ,
1065- value ,
1066- wait = True ,
1067- )
1068- assert put_ret .ok , "caput did not succeed"
10691049
1070- ret_val = caget (
1071- DEVICE_NAME + ":" + "VALIDATE-RECORD" ,
1072- timeout = 3
1073- )
1050+ @ requires_cothread
1051+ def test_validate_blocks_updates ( self , out_records ):
1052+ """Test that record values are not updated when validate method
1053+ always blocks updates"""
10741054
1075- if creation_func in [builder .WaveformOut , builder .WaveformIn ]:
1076- assert numpy .array_equal (ret_val , default )
1077- else :
1078- assert ret_val == default
1055+ creation_func , value , default = out_records
10791056
1080- finally :
1081- process .terminate ()
1082- process .join (timeout = 3 )
1057+ self .validate_test_runner (creation_func , value , default , False )
0 commit comments