class_docstr: Tests for the qubit reuse/reset functionality of `qml.measure`.
docstr: Test that qubit reuse related logic is applied if a wire with mid-circuit
  measurements is included in terminal measurements.
docstr_tok: ["Test","that","qubit","reuse","related","logic","is","applied","if","a","wire","with","mid-circuit","measurements","is","included","in","terminal","measurements","."]
code: def test_measurements_add_new_qubits(self):
      """Test that qubit reuse related logic is applied if a wire with mid-circuit
      measurements is included in terminal measurements."""
      tape = qml.tape.QuantumScript(
          ops=[qml.Hadamard(0), MidMeasureMP(0)],
          measurements=[qml.density_matrix(wires=[0])],
      )
      expected = np.eye(2) / 2
  
      tapes, _ = qml.defer_measurements(tape)
  
      dev = qml.device("default.qubit")
      res = qml.execute(tapes, dev)
  
      assert np.allclose(res, expected)
  
      deferred_tape = tapes[0]
      assert deferred_tape.operations == [
          qml.Hadamard(0),
          qml.CNOT([0, 1]),
      ]
      assert deferred_tape.measurements == [
          qml.density_matrix(wires=[0])
      ]
  
imports: import math
  import pytest
  import pennylane
  from pennylane.measurements import MidMeasureMP, MeasurementValue
  import pennylane.numpy
  from pennylane.devices import DefaultQubit
label_desc: Use image node_id 3 for calling the TestQubitReuseAndReset obj's underlying member method code with example usage: obj.test_measurements_add_new_qubits() without return types