15
15
DummyChannel ,
16
16
DummyChannelInstrument ,
17
17
)
18
+ from qcodes .utils import QCoDeSDeprecationWarning
18
19
19
20
if TYPE_CHECKING :
20
21
import pytest_mock
@@ -538,6 +539,9 @@ def test_set_element_by_slice(dci_with_list: DCIWithList) -> None:
538
539
assert (
539
540
dci_with_list .channels .get_channel_by_name ("bar" ) == dci_with_list .channels [1 ]
540
541
)
542
+ channels_by_name = dci_with_list .channels .get_channels_by_name ("foo" , "bar" )
543
+ for i , chan in enumerate (channels_by_name ):
544
+ assert chan == dci_with_list .channels [i ]
541
545
542
546
543
547
def test_set_element_locked_raises (dci_with_list : DCIWithList ) -> None :
@@ -552,13 +556,33 @@ def test_set_element_locked_raises(dci_with_list: DCIWithList) -> None:
552
556
553
557
@settings (suppress_health_check = (HealthCheck .function_scoped_fixture ,), deadline = 1000 )
554
558
@given (myindexs = hst .lists (elements = hst .integers (0 , 7 ), min_size = 2 ))
555
- def test_access_channels_by_name (dci , myindexs ) -> None :
559
+ def test_access_channels_by_name_deprecated (
560
+ dci : DummyChannelInstrument , myindexs : list [int ]
561
+ ) -> None :
562
+ names = ("A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" )
563
+ channels = tuple (DummyChannel (dci , "Chan" + name , name ) for name in names )
564
+ chlist = ChannelList (dci , "channels" , DummyChannel , channels )
565
+
566
+ channel_names = (f"Chan{ names [i ]} " for i in myindexs )
567
+
568
+ with pytest .warns (QCoDeSDeprecationWarning , match = "get_channel_by_name" ):
569
+ mychans = chlist .get_channel_by_name (* channel_names )
570
+ for chan , chanindex in zip (mychans , myindexs ):
571
+ assert chan .name == f"dci_Chan{ names [chanindex ]} "
572
+
573
+
574
+ @settings (suppress_health_check = (HealthCheck .function_scoped_fixture ,), deadline = 1000 )
575
+ @given (myindexs = hst .lists (elements = hst .integers (0 , 7 ), min_size = 1 ))
576
+ def test_access_channels_by_name (
577
+ dci : DummyChannelInstrument , myindexs : list [int ]
578
+ ) -> None :
556
579
names = ("A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" )
557
580
channels = tuple (DummyChannel (dci , "Chan" + name , name ) for name in names )
558
581
chlist = ChannelList (dci , "channels" , DummyChannel , channels )
559
582
560
583
channel_names = (f"Chan{ names [i ]} " for i in myindexs )
561
- mychans = chlist .get_channel_by_name (* channel_names )
584
+
585
+ mychans = chlist .get_channels_by_name (* channel_names )
562
586
for chan , chanindex in zip (mychans , myindexs ):
563
587
assert chan .name == f"dci_Chan{ names [chanindex ]} "
564
588
0 commit comments