@@ -96,6 +96,8 @@ def test_instrument_on_invalid_identifier(close_before_and_after):
96
96
assert DummyInstrument .instances () == []
97
97
assert Instrument ._all_instruments == {}
98
98
99
+
100
+ def test_instrument_warns_on_hyphen_in_name (close_before_and_after ):
99
101
# Check if warning is raised and name is valid
100
102
# identifier when dashes '-' are converted to underscores '_'
101
103
with pytest .warns (
@@ -109,6 +111,25 @@ def test_instrument_on_invalid_identifier(close_before_and_after):
109
111
assert Instrument ._all_instruments != {}
110
112
111
113
114
+ def test_instrument_allows_channel_name_starting_with_number (close_before_and_after ):
115
+ instr = DummyChannelInstrument (name = "foo" , channel_names = ["1" , "2" , "3" ])
116
+
117
+ for chan in instr .channels :
118
+ assert chan .short_name .isidentifier () is False
119
+ assert chan .full_name .isidentifier () is True
120
+ assert Instrument .instances () == []
121
+ assert DummyChannelInstrument .instances () == [instr ]
122
+ assert Instrument ._all_instruments != {}
123
+
124
+
125
+ def test_instrument_channel_name_raise_on_invalid (close_before_and_after ):
126
+ with pytest .raises (ValueError , match = "foo_☃ invalid instrument identifier" ):
127
+ DummyChannelInstrument (name = "foo" , channel_names = ["☃" ])
128
+ assert Instrument .instances () == []
129
+ assert DummyChannelInstrument .instances () == []
130
+ assert Instrument ._all_instruments == {}
131
+
132
+
112
133
def test_instrument_retry_with_same_name (close_before_and_after ):
113
134
with pytest .raises (RuntimeError , match = "Failed to create instrument" ):
114
135
DummyFailingInstrument (name = "failinginstrument" )
0 commit comments