Repository: Qiskit/qiskit

Issue:
Controlled Gate .draw() error: method draws incorrect gate if amount of control qubits < 3
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: 0.18.0
- **Python version**: 3.7.4 (default, Aug 13 2019, 20:35:49) [GCC 7.3.0]
- **Operating system**: Linux
- *Qiskit Aqua version**: 0.7.0
That's not a "standard" versions set, expected Aqua version is 0.6.5.
Unfortunately, Controlled gates don't work at all with the standard Qiskit 0.18.0 setup.
See details at the [4175](https://github.com/Qiskit/qiskit-terra/issues/4175) bug investigation.

### What is the current behavior?
Anti-contolled gates with 1 or 2 control qubits aren't displayed correcly

### Steps to reproduce the problem
In the Jupyter notebook cell execute code
```
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer
from qiskit.extensions.standard import XGate
import qiskit.tools.jupyter
%qiskit_version_table
qreg = QuantumRegister(5) 
qc = QuantumCircuit(qreg)
control1 = XGate().control(1, ctrl_state='0')
qc.append(control1, [0, 1])
control2 = XGate().control(2, ctrl_state='00')
qc.append(control2, [0, 1, 2])
control2_2 = XGate().control(2, ctrl_state='10')
qc.append(control2_2, [0, 1, 2])
control3 = XGate().control(3, ctrl_state='010')
qc.append(control3, [0, 1, 2, 3])
qc.draw()
```

The result is
![image](https://user-images.githubusercontent.com/6274989/79685660-21389f00-8243-11ea-9396-bc600960fa01.png)

### What is the expected behavior?

1. q0 control symbol should be "empty circle" in the first gate;
2. q0 and q1 control symbols should be "empty circle" in the second gate;
3. one control symbols should be "empty circle" in the thrid gate;
4. fourth gate is visualized correctly.

I'm not sure where the issue is: in the visualization part, or in the gate part.

**Update 1**: I wrote an additional test. The controlled gate is formed and computed incorrectly. A code below generates a standard "CNOT" gate instead of anti-controlled not:
```
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute, Aer
from qiskit.extensions.standard import XGate

simulator = Aer.get_backend('qasm_simulator')
qreg = QuantumRegister(2) 
creg = ClassicalRegister(2)
qc = QuantumCircuit(qreg, creg)

#qc.x(qreg[0])
control1 = XGate().control(1, ctrl_state='0')
qc.append(control1, [0, 1])
qc.measure(qreg,creg)   

job = execute(qc, simulator, shots=1000)
result = job.result()
counts = result.get_counts(qc)
print("\nTotal count for 00 and 11 are:",counts)
qc.draw()
```
A circuit and results:
![image](https://user-images.githubusercontent.com/6274989/79686014-c6ed0d80-8245-11ea-919e-9c0ae48f3878.png)
With the anti-controlled not only '01' should be measured.




add visualization of open controlled gates [mpl drawer]
@ewinston says in https://github.com/Qiskit/qiskit-terra/issues/3864:
> In PR #3739, open controlled gates were implemented. With that PR a new keyword argument was added to specify the control state,
> 
> `XGate().control(3, ctrl_state=6)`
> 
> This creates a 4 qubit gate where the first three qubits are controls and the fourth qubit is the target where the x-gate may be applied. A `ctrl_state` may alternatively be expressed as an integer string,
> 
> `XGate().control(3, ctrl_state='110')`
> 
> where it is more apparent which qubits are open and closed. In this case when q[0] is open and q[1] and q[2] are closed the x-gate will be applied to q[4].

As a reference https://github.com/Qiskit/qiskit-terra/pull/3867 implements open controlled gates for the text visualizer like this:
```python
qr = QuantumRegister(4, 'q')
circuit = QuantumCircuit(qr)
circuit.append(U2Gate(pi, -5 * pi / 8).control(3, ctrl_state='100'),
               [qr[0], qr[3], qr[2], qr[1]])
circuit.draw('text')
```
```
                         
q_0: |0>────────o────────
        ┌───────┴───────┐
q_1: |0>┤ U2(pi,-5pi/8) ├
        └───────┬───────┘
q_2: |0>────────■────────
                │        
q_3: |0>────────o────────
```
The current output for `circuit.draw('mpl')` is:
![image](https://user-images.githubusercontent.com/766693/76469326-72dc4700-63c4-11ea-896c-32f28a70d362.png)



Discussion:

Hi @ewinston , I am new to qiskit, but I would like to work on it if you don't mind. 
@1ucian0, I played around with this a bit and think I know how to make the changes. I'm not sure if @JayantiSingh is still interested, but if not, I can take it on.
Let's give Jayanti Singh <https://github.com/JayantiSingh> two or three
days for a ping. If silence, go ahead!

On Tue, Apr 7, 2020, 11:08 PM enavarro51 <notifications@github.com> wrote:

> @1ucian0 <https://github.com/1ucian0>, I played around with this a bit
> and think I know how to make the changes. I'm not sure if @JayantiSingh
> <https://github.com/JayantiSingh> is still interested, but if not, I can
> take it on.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/Qiskit/qiskit-terra/issues/3957#issuecomment-610726799>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAF3FZNMBVFTTFBNPXWOM43RLPTDBANCNFSM4LF7YWDQ>
> .
>

Haven't heard any pinging. Shall I proceed?
Sure! Let me know if you need any pointers!

On Fri, Apr 10, 2020, 11:33 AM Edwin Navarro <notifications@github.com>
wrote:

> Haven't heard any pinging. Shall I proceed?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/Qiskit/qiskit-terra/issues/3957#issuecomment-612081741>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAF3FZIJ74WPM4DNTW3XLTDRL435DANCNFSM4LF7YWDQ>
> .
>

Thanks, Luciano. I'd already started working on it, and this is what I have done. Given this code,
```
from qiskit import QuantumRegister, QuantumCircuit
from qiskit.extensions import U3Gate, U2Gate
import numpy as np

pi = np.pi
qr = QuantumRegister(4, 'q')
circuit = QuantumCircuit(qr)
circuit.append(U2Gate(pi/8,pi/8).control(3, ctrl_state=2),
               [qr[0], qr[3], qr[2], qr[1]])
circuit.append(U3Gate(3*pi/4,3*pi/4,3*pi/4).control(3, ctrl_state='101'),
               [qr[0], qr[3], qr[2], qr[1]])
circuit.draw(output='mpl')
```
![image](https://user-images.githubusercontent.com/16268251/79051758-da193100-7be6-11ea-87ce-c1f43e22d437.png)
Is this what you are looking for? I also have a couple of questions.
- Most of this was pretty straightforward, but the layer_width for these ControlledGates was not working correctly. Gates were jumping to very wide spacing. There were two sections in the code for layer_width and these gates fell into a default area. I decided not to change the other 2 sections, but  added a new section for these gates only. I did a lot of testing on the layer width to make sure the boxes were as close as possible horizontally without touching., There are a lot of possible combinations of these gates, though, and I'm wondering if additional QA would be in order.
- Since the output of this code is visual, I'm not sure how one would create a test for this. Any suggestions would help.
Thanks.

Resolving patch:
diff --git a/qiskit/visualization/text.py b/qiskit/visualization/text.py
--- a/qiskit/visualization/text.py
+++ b/qiskit/visualization/text.py
@@ -838,6 +838,21 @@ def controlled_wires(instruction, layer):
                 in_box.append(ctrl_qubit)
         return (top_box, bot_box, in_box, args_qubits)
 
+    def _set_ctrl_state(self, instruction, conditional):
+        """ Takes the ctrl_state from instruction and appends Bullet or OpenBullet
+        to gates depending on whether the bit in ctrl_state is 1 or 0. Returns gates"""
+
+        gates = []
+        num_ctrl_qubits = instruction.op.num_ctrl_qubits
+        ctrl_qubits = instruction.qargs[:num_ctrl_qubits]
+        cstate = "{0:b}".format(instruction.op.ctrl_state).rjust(num_ctrl_qubits, '0')[::-1]
+        for i in range(len(ctrl_qubits)):
+            if cstate[i] == '1':
+                gates.append(Bullet(conditional=conditional))
+            else:
+                gates.append(OpenBullet(conditional=conditional))
+        return gates
+
     def _instruction_to_gate(self, instruction, layer):
         """ Convert an instruction into its corresponding Gate object, and establish
         any connections it introduces between qubits"""
@@ -885,57 +900,15 @@ def add_connected_gate(instruction, gates, layer, current_cons):
             gates = [Ex(conditional=conditional) for _ in range(len(instruction.qargs))]
             add_connected_gate(instruction, gates, layer, current_cons)
 
-        elif instruction.name == 'cswap':
-            # cswap
-            gates = [Bullet(conditional=conditional),
-                     Ex(conditional=conditional),
-                     Ex(conditional=conditional)]
-            add_connected_gate(instruction, gates, layer, current_cons)
-
         elif instruction.name == 'reset':
             layer.set_qubit(instruction.qargs[0], Reset(conditional=conditional))
 
-        elif instruction.name in ['cx', 'CX', 'ccx']:
-            # cx/ccx
-            gates = [Bullet(conditional=conditional) for _ in range(len(instruction.qargs) - 1)]
-            gates.append(BoxOnQuWire('X', conditional=conditional))
-            add_connected_gate(instruction, gates, layer, current_cons)
-
-        elif instruction.name == 'cy':
-            # cy
-            gates = [Bullet(conditional=conditional), BoxOnQuWire('Y')]
-            add_connected_gate(instruction, gates, layer, current_cons)
-
-        elif instruction.name == 'cz' and instruction.op.ctrl_state == 1:
-            # cz TODO: only supports one closed controlled for now
-            gates = [Bullet(conditional=conditional), Bullet(conditional=conditional)]
-            add_connected_gate(instruction, gates, layer, current_cons)
-
-        elif instruction.name == 'cu1':
-            # cu1
-            connection_label = TextDrawing.params_for_label(instruction)[0]
-            gates = [Bullet(conditional=conditional), Bullet(conditional=conditional)]
-            add_connected_gate(instruction, gates, layer, current_cons)
-
         elif instruction.name == 'rzz':
             # rzz
             connection_label = "zz(%s)" % TextDrawing.params_for_label(instruction)[0]
             gates = [Bullet(conditional=conditional), Bullet(conditional=conditional)]
             add_connected_gate(instruction, gates, layer, current_cons)
 
-        elif instruction.name == 'cu3':
-            # cu3
-            params = TextDrawing.params_for_label(instruction)
-            gates = [Bullet(conditional=conditional),
-                     BoxOnQuWire("U3(%s)" % ','.join(params), conditional=conditional)]
-            add_connected_gate(instruction, gates, layer, current_cons)
-
-        elif instruction.name == 'crz':
-            # crz
-            label = "Rz(%s)" % TextDrawing.params_for_label(instruction)[0]
-            gates = [Bullet(conditional=conditional), BoxOnQuWire(label, conditional=conditional)]
-            add_connected_gate(instruction, gates, layer, current_cons)
-
         elif len(instruction.qargs) == 1 and not instruction.cargs:
             # unitary gate
             layer.set_qubit(instruction.qargs[0],
@@ -944,17 +917,24 @@ def add_connected_gate(instruction, gates, layer, current_cons):
 
         elif isinstance(instruction.op, ControlledGate):
             label = TextDrawing.label_for_box(instruction, controlled=True)
-            gates = []
-
             params_array = TextDrawing.controlled_wires(instruction, layer)
             controlled_top, controlled_bot, controlled_edge, rest = params_array
-            for i in controlled_top + controlled_bot + controlled_edge:
-                if i[1] == '1':
-                    gates.append(Bullet(conditional=conditional))
-                else:
-                    gates.append(OpenBullet(conditional=conditional))
+            gates = self._set_ctrl_state(instruction, conditional)
             if instruction.op.base_gate.name == 'z':
+                # cz
+                gates.append(Bullet(conditional=conditional))
+            elif instruction.op.base_gate.name == 'u1':
+                # cu1
+                connection_label = TextDrawing.params_for_label(instruction)[0]
                 gates.append(Bullet(conditional=conditional))
+            elif instruction.op.base_gate.name == 'swap':
+                # cswap
+                gates += [Ex(conditional=conditional), Ex(conditional=conditional)]
+                add_connected_gate(instruction, gates, layer, current_cons)
+            elif instruction.op.base_gate.name == 'rzz':
+                # crzz
+                connection_label = "zz(%s)" % TextDrawing.params_for_label(instruction)[0]
+                gates += [Bullet(conditional=conditional), Bullet(conditional=conditional)]
             elif len(rest) > 1:
                 top_connect = '┴' if controlled_top else None
                 bot_connect = '┬' if controlled_bot else None
@@ -965,6 +945,8 @@ def add_connected_gate(instruction, gates, layer, current_cons):
                 for index in range(min(indexes), max(indexes) + 1):
                     # Dummy element to connect the multibox with the bullets
                     current_cons.append((index, DrawElement('')))
+            elif instruction.op.base_gate.name == 'z':
+                gates.append(Bullet(conditional=conditional))
             else:
                 gates.append(BoxOnQuWire(label, conditional=conditional))
             add_connected_gate(instruction, gates, layer, current_cons)


Test patch:
diff --git a/test/python/visualization/test_circuit_text_drawer.py b/test/python/visualization/test_circuit_text_drawer.py
--- a/test/python/visualization/test_circuit_text_drawer.py
+++ b/test/python/visualization/test_circuit_text_drawer.py
@@ -28,7 +28,8 @@
 from qiskit.transpiler import Layout
 from qiskit.visualization import text as elements
 from qiskit.visualization.circuit_visualization import _text_circuit_drawer
-from qiskit.extensions import HGate, U2Gate, XGate, UnitaryGate, CZGate, ZGate
+from qiskit.extensions import HGate, U2Gate, XGate, UnitaryGate, CZGate, ZGate, YGate, U1Gate, \
+    SwapGate, RZZGate
 from qiskit.extensions.hamiltonian_gate import HamiltonianGate
 
 
@@ -2218,7 +2219,7 @@ def test_controlled_composite_gate_bot(self):
     def test_controlled_composite_gate_top_bot(self):
         """Controlled composite gates (top and bottom) """
         expected = '\n'.join(["                ",
-                              "q_0: |0>───■────",
+                              "q_0: |0>───o────",
                               "        ┌──┴───┐",
                               "q_1: |0>┤0     ├",
                               "        │      │",
@@ -2226,7 +2227,7 @@ def test_controlled_composite_gate_top_bot(self):
                               "        │      │",
                               "q_3: |0>┤2     ├",
                               "        └──┬───┘",
-                              "q_4: |0>───o────",
+                              "q_4: |0>───■────",
                               "                "])
         ghz_circuit = QuantumCircuit(3, name='ghz')
         ghz_circuit.h(0)
@@ -2265,6 +2266,192 @@ def test_controlled_composite_gate_all(self):
 
         self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
 
+    def test_open_controlled_x(self):
+        """Controlled X gates.
+        See https://github.com/Qiskit/qiskit-terra/issues/4180"""
+        expected = '\n'.join(["                                  ",
+                              "qr_0: |0>──o────o────o────o────■──",
+                              "         ┌─┴─┐  │    │    │    │  ",
+                              "qr_1: |0>┤ X ├──o────■────■────o──",
+                              "         └───┘┌─┴─┐┌─┴─┐  │    │  ",
+                              "qr_2: |0>─────┤ X ├┤ X ├──o────o──",
+                              "              └───┘└───┘┌─┴─┐┌─┴─┐",
+                              "qr_3: |0>───────────────┤ X ├┤ X ├",
+                              "                        └───┘└─┬─┘",
+                              "qr_4: |0>──────────────────────■──",
+                              "                                  "])
+        qreg = QuantumRegister(5, 'qr')
+        circuit = QuantumCircuit(qreg)
+        control1 = XGate().control(1, ctrl_state='0')
+        circuit.append(control1, [0, 1])
+        control2 = XGate().control(2, ctrl_state='00')
+        circuit.append(control2, [0, 1, 2])
+        control2_2 = XGate().control(2, ctrl_state='10')
+        circuit.append(control2_2, [0, 1, 2])
+        control3 = XGate().control(3, ctrl_state='010')
+        circuit.append(control3, [0, 1, 2, 3])
+        control3 = XGate().control(4, ctrl_state='0101')
+        circuit.append(control3, [0, 1, 4, 2, 3])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
+
+    def test_open_controlled_y(self):
+        """Controlled Y gates.
+        See https://github.com/Qiskit/qiskit-terra/issues/4180"""
+        expected = '\n'.join(["                                  ",
+                              "qr_0: |0>──o────o────o────o────■──",
+                              "         ┌─┴─┐  │    │    │    │  ",
+                              "qr_1: |0>┤ Y ├──o────■────■────o──",
+                              "         └───┘┌─┴─┐┌─┴─┐  │    │  ",
+                              "qr_2: |0>─────┤ Y ├┤ Y ├──o────o──",
+                              "              └───┘└───┘┌─┴─┐┌─┴─┐",
+                              "qr_3: |0>───────────────┤ Y ├┤ Y ├",
+                              "                        └───┘└─┬─┘",
+                              "qr_4: |0>──────────────────────■──",
+                              "                                  "])
+        qreg = QuantumRegister(5, 'qr')
+        circuit = QuantumCircuit(qreg)
+        control1 = YGate().control(1, ctrl_state='0')
+        circuit.append(control1, [0, 1])
+        control2 = YGate().control(2, ctrl_state='00')
+        circuit.append(control2, [0, 1, 2])
+        control2_2 = YGate().control(2, ctrl_state='10')
+        circuit.append(control2_2, [0, 1, 2])
+        control3 = YGate().control(3, ctrl_state='010')
+        circuit.append(control3, [0, 1, 2, 3])
+        control3 = YGate().control(4, ctrl_state='0101')
+        circuit.append(control3, [0, 1, 4, 2, 3])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
+
+    def test_open_controlled_z(self):
+        """Controlled Z gates."""
+        expected = '\n'.join(["                        ",
+                              "qr_0: |0>─o──o──o──o──■─",
+                              "          │  │  │  │  │ ",
+                              "qr_1: |0>─■──o──■──■──o─",
+                              "             │  │  │  │ ",
+                              "qr_2: |0>────■──■──o──o─",
+                              "                   │  │ ",
+                              "qr_3: |0>──────────■──■─",
+                              "                      │ ",
+                              "qr_4: |0>─────────────■─",
+                              "                        "])
+        qreg = QuantumRegister(5, 'qr')
+        circuit = QuantumCircuit(qreg)
+        control1 = ZGate().control(1, ctrl_state='0')
+        circuit.append(control1, [0, 1])
+        control2 = ZGate().control(2, ctrl_state='00')
+        circuit.append(control2, [0, 1, 2])
+        control2_2 = ZGate().control(2, ctrl_state='10')
+        circuit.append(control2_2, [0, 1, 2])
+        control3 = ZGate().control(3, ctrl_state='010')
+        circuit.append(control3, [0, 1, 2, 3])
+        control3 = ZGate().control(4, ctrl_state='0101')
+        circuit.append(control3, [0, 1, 4, 2, 3])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
+
+    def test_open_controlled_u1(self):
+        """Controlled U1 gates."""
+        expected = '\n'.join(["                                       ",
+                              "qr_0: |0>─o─────o─────o─────o─────■────",
+                              "          │0.1  │     │     │     │    ",
+                              "qr_1: |0>─■─────o─────■─────■─────o────",
+                              "                │0.2  │0.3  │     │    ",
+                              "qr_2: |0>───────■─────■─────o─────o────",
+                              "                            │0.4  │    ",
+                              "qr_3: |0>───────────────────■─────■────",
+                              "                                  │0.5 ",
+                              "qr_4: |0>─────────────────────────■────",
+                              "                                       "])
+        qreg = QuantumRegister(5, 'qr')
+        circuit = QuantumCircuit(qreg)
+        control1 = U1Gate(0.1).control(1, ctrl_state='0')
+        circuit.append(control1, [0, 1])
+        control2 = U1Gate(0.2).control(2, ctrl_state='00')
+        circuit.append(control2, [0, 1, 2])
+        control2_2 = U1Gate(0.3).control(2, ctrl_state='10')
+        circuit.append(control2_2, [0, 1, 2])
+        control3 = U1Gate(0.4).control(3, ctrl_state='010')
+        circuit.append(control3, [0, 1, 2, 3])
+        control3 = U1Gate(0.5).control(4, ctrl_state='0101')
+        circuit.append(control3, [0, 1, 4, 2, 3])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
+
+    def test_open_controlled_swap(self):
+        """Controlled SWAP gates."""
+        expected = '\n'.join(["                     ",
+                              "qr_0: |0>─o──o──o──o─",
+                              "          │  │  │  │ ",
+                              "qr_1: |0>─X──o──■──■─",
+                              "          │  │  │  │ ",
+                              "qr_2: |0>─X──X──X──o─",
+                              "             │  │  │ ",
+                              "qr_3: |0>────X──X──X─",
+                              "                   │ ",
+                              "qr_4: |0>──────────X─",
+                              "                     "])
+        qreg = QuantumRegister(5, 'qr')
+        circuit = QuantumCircuit(qreg)
+        control1 = SwapGate().control(1, ctrl_state='0')
+        circuit.append(control1, [0, 1, 2])
+        control2 = SwapGate().control(2, ctrl_state='00')
+        circuit.append(control2, [0, 1, 2, 3])
+        control2_2 = SwapGate().control(2, ctrl_state='10')
+        circuit.append(control2_2, [0, 1, 2, 3])
+        control3 = SwapGate().control(3, ctrl_state='010')
+        circuit.append(control3, [0, 1, 2, 3, 4])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
+
+    def test_open_controlled_rzz(self):
+        """Controlled RZZ gates."""
+        expected = '\n'.join(["                                         ",
+                              "qr_0: |0>─o───────o───────o───────o──────",
+                              "          │       │       │       │      ",
+                              "qr_1: |0>─■───────o───────■───────■──────",
+                              "          │zz(1)  │       │       │      ",
+                              "qr_2: |0>─■───────■───────■───────o──────",
+                              "                  │zz(1)  │zz(1)  │      ",
+                              "qr_3: |0>─────────■───────■───────■──────",
+                              "                                  │zz(1) ",
+                              "qr_4: |0>─────────────────────────■──────",
+                              "                                         "])
+        qreg = QuantumRegister(5, 'qr')
+        circuit = QuantumCircuit(qreg)
+        control1 = RZZGate(1).control(1, ctrl_state='0')
+        circuit.append(control1, [0, 1, 2])
+        control2 = RZZGate(1).control(2, ctrl_state='00')
+        circuit.append(control2, [0, 1, 2, 3])
+        control2_2 = RZZGate(1).control(2, ctrl_state='10')
+        circuit.append(control2_2, [0, 1, 2, 3])
+        control3 = RZZGate(1).control(3, ctrl_state='010')
+        circuit.append(control3, [0, 1, 2, 3, 4])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
+
+    def test_open_out_of_order(self):
+        """Out of order CXs
+        See: https://github.com/Qiskit/qiskit-terra/issues/4052#issuecomment-613736911 """
+        expected = '\n'.join(["             ",
+                              "q_0: |0>──■──",
+                              "          │  ",
+                              "q_1: |0>──■──",
+                              "        ┌─┴─┐",
+                              "q_2: |0>┤ X ├",
+                              "        └─┬─┘",
+                              "q_3: |0>──o──",
+                              "             ",
+                              "q_4: |0>─────",
+                              "             "])
+        qr = QuantumRegister(5, 'q')
+        circuit = QuantumCircuit(qr)
+        circuit.append(XGate().control(3, ctrl_state='101'), [qr[0], qr[3], qr[1], qr[2]])
+
+        self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
+
 
 class TestTextWithLayout(QiskitTestCase):
     """The with_layout option"""