class_docstr: Tests for the hamiltonian_expand transform
class_docstr_tok: ["Tests","for","the","hamiltonian_expand","transform"]
docstr: Tests that the script passed to hamiltonian_expand must end with a hamiltonian.
docstr_tok: ["Tests","that","the","script","passed","to","hamiltonian_expand","must","end","with","a","hamiltonian","."]
code: def test_hamiltonian_error(self):
      """Tests that the script passed to hamiltonian_expand must end with a hamiltonian."""
      qscript = QuantumScript(measurements=[qml.expval(qml.PauliZ(0))])
  
      with pytest.raises(ValueError, match=r"Passed tape must end in"):
          qml.transforms.hamiltonian_expand(qscript)
  
imports: import numpy
  import pytest
  import pennylane
  from pennylane import numpy
  from pennylane.queuing import AnnotatedQueue
  from pennylane.tape import QuantumScript
  from pennylane.transforms import hamiltonian_expand, sum_expand
label_desc: Use image node_id 8 for calling the TestHamiltonianExpand obj's underlying member method code with example usage: obj.test_hamiltonian_error() without return types