34
34
class TestWires :
35
35
"""Tests for the ``Wires`` class."""
36
36
37
+ def test_wires_object_as_label (self ):
38
+ """Tests that a Wires object can be used as a label for another Wires object."""
39
+ assert Wires ([0 , 1 ]) == Wires ([Wires ([0 ]), Wires ([1 ])])
40
+ assert Wires (["a" , "b" , 1 ]) == Wires ([Wires (["a" , "b" ]), Wires ([1 ])])
41
+ assert Wires ([Wires ([(0 , 0 ), (0 , 1 )])]) == Wires ([(0 , 0 ), (0 , 1 )])
42
+
37
43
def test_error_if_wires_none (self ):
38
44
"""Tests that a TypeError is raised if None is given as wires."""
39
45
with pytest .raises (TypeError , match = "Must specify a set of wires." ):
@@ -74,7 +80,7 @@ def test_creation_from_wires_lists(self):
74
80
"""Tests that a Wires object can be created from a list of Wires."""
75
81
76
82
wires = Wires ([Wires ([0 ]), Wires ([1 ]), Wires ([2 ])])
77
- assert wires .labels == (Wires ([ 0 ]), Wires ([ 1 ]), Wires ([ 2 ]) )
83
+ assert wires .labels == (0 , 1 , 2 )
78
84
79
85
@pytest .mark .parametrize (
80
86
"iterable" , [[1 , 0 , 4 ], ["a" , "b" , "c" ], [0 , 1 , None ], ["a" , 1 , "ancilla" ]]
@@ -148,7 +154,7 @@ def test_contains(
148
154
wires = Wires ([0 , 1 , 2 , 3 , Wires ([4 , 5 ]), None ])
149
155
150
156
assert 0 in wires
151
- assert Wires ([4 , 5 ]) in wires
157
+ assert Wires ([4 , 5 ]) not in wires
152
158
assert None in wires
153
159
assert Wires ([1 ]) not in wires
154
160
assert Wires ([0 , 3 ]) not in wires
@@ -170,7 +176,7 @@ def test_contains_wires(
170
176
171
177
assert not wires .contains_wires (0 ) # wrong type
172
178
assert not wires .contains_wires ([0 , 1 ]) # wrong type
173
- assert not wires .contains_wires (
179
+ assert wires .contains_wires (
174
180
Wires ([4 , 5 ])
175
181
) # looks up 4 and 5 in wires, which are not present
176
182
0 commit comments