99 log ,
1010 create_random_prefix ,
1111 requires_cothread ,
12- _clear_records ,
1312 WAVEFORM_LENGTH ,
1413 TIMEOUT ,
1514 select_and_recv ,
1918from softioc import asyncio_dispatcher , builder , softioc
2019from softioc import alarm
2120from softioc .device import SetBlocking
21+ from softioc .device_core import LookupRecord , LookupRecordList
2222
2323# Test file for miscellaneous tests related to records
2424
@@ -38,7 +38,6 @@ def test_records(tmp_path):
3838 # Ensure we definitely unload all records that may be hanging over from
3939 # previous tests, then create exactly one instance of expected records.
4040 from sim_records import create_records
41- _clear_records ()
4241 create_records ()
4342
4443 path = str (tmp_path / "records.db" )
@@ -228,6 +227,29 @@ def test_setting_alarm_invalid_keywords(creation_func):
228227
229228 assert e .value .args [0 ] == 'Can\' t specify both status and STAT'
230229
230+ def test_clear_records ():
231+ """Test that clearing the known records allows creation of a record of the
232+ same name afterwards"""
233+ record_name = "NEW-RECORD"
234+
235+ builder .aOut (record_name )
236+
237+ # First check that we cannot create two of the same name
238+ with pytest .raises (AssertionError ):
239+ builder .aOut (record_name )
240+
241+ builder .ClearRecords ()
242+
243+ # Then confirm we can create one of this name
244+ builder .aOut (record_name )
245+
246+ # Finally prove that the underlying record holder contains only one record
247+ assert LookupRecord (record_name )
248+ assert len (LookupRecordList ()) == 1
249+ for key , val in LookupRecordList ():
250+ assert key == record_name
251+
252+
231253
232254def validate_fixture_names (params ):
233255 """Provide nice names for the out_records fixture in TestValidate class"""
0 commit comments