class_docstr: Unit tests for the batch_transform class
class_docstr_tok: ["Unit","tests","for","the","batch_transform","class"]
docstr: Test that if an expansion function is provided,
  that the input tape is expanded before being transformed.
docstr_tok: ["Test","that","if","an","expansion","function","is","provided",",","that","the","input","tape","is","expanded","before","being","transformed","."]
code: def test_expand_fn(self, mocker):
      """Test that if an expansion function is provided,
      that the input tape is expanded before being transformed."""
  
      class MyTransform:
          """Dummy class to allow spying to work"""
  
          def my_transform(self, tape):
              tape1 = tape.copy()
              tape2 = tape.copy()
              return [tape1, tape2], None
  
      spy_transform = mocker.spy(MyTransform, "my_transform")
      transform_fn = qml.batch_transform(
          MyTransform().my_transform, expand_fn=self.phaseshift_expand
      )
  
      with qml.queuing.AnnotatedQueue() as q:
          qml.PhaseShift(0.5, wires=0)
          qml.expval(qml.PauliX(0))
  
      tape = qml.tape.QuantumScript.from_queue(q)
      spy_expand = mocker.spy(transform_fn, "expand_fn")
  
      transform_fn(tape)
  
      spy_transform.assert_called()
      spy_expand.assert_called()
  
      input_tape = spy_transform.call_args[0][1]
      assert len(input_tape.operations) == 2
      assert input_tape.operations[0].name == "RZ"
      assert input_tape.operations[1].name == "GlobalPhase"
      assert input_tape.operations[0].parameters == [0.5]
      assert input_tape.operations[1].parameters == [-0.25]
  
imports: import functools
  import pytest
  import pennylane
  from pennylane import numpy
label_desc: Use image node_id 10 for calling the TestBatchTransform obj's underlying member method code with example usage: obj.test_expand_fn(mocker) and returns: list,  None