Repository: PennyLaneAI/pennylane
Pull request #5951 (2024-07-04 20:41:12)

Fix `test_return_system`
### Before submitting

Please complete the following checklist when submitting a PR:

- [x] All new features must include a unit test.
      If you've fixed a bug or added code that should be tested, add a test to the
      test directory!

- [x] All new functions and code must be clearly commented and documented.
      If you do make documentation changes, make sure that the docs build and
      render correctly by running `make docs`.

- [x] Ensure that the test suite passes, by running `make test`.

- [x] Add a new entry to the `doc/releases/changelog-dev.md` file, summarizing the
      change, and including a link back to the PR.

- [x] The PennyLane source code conforms to
      [PEP8 standards](https://www.python.org/dev/peps/pep-0008/).
      We check all of our code against [Pylint](https://www.pylint.org/).
      To lint modified files, simply `pip install pylint`, and then
      run `pylint pennylane/path/to/file.py`.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.

------------------------------------------------------------------------------------------------------------

**Context:**
Lightning-GPU fails some tests that it should in fact skip.

**Description of the Change:**
Skip measurement-of-projector tests if it is not supported.

**Benefits:**

**Possible Drawbacks:**

**Related GitHub Issues:**


github-actions[bot]: Hello. You may have forgotten to update the changelog!
Please edit [`doc/releases/changelog-dev.md`](/PennyLaneAI/pennylane/blob/master/doc/releases/changelog-dev.md) with:
* A one-to-two sentence description of the change. You may include a small working example for new features.
* A link back to this PR.
* Your name (or GitHub username) in the contributors section.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/PennyLaneAI/pennylane/pull/5951?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Please [upload](https://docs.codecov.com/docs/codecov-uploader) report for BASE (`v0.37.0-rc0@540429d`). [Learn more](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI#section-missing-base-commit) about missing BASE report.

<details><summary>Additional details and impacted files</summary>


```diff
@@              Coverage Diff               @@
##             v0.37.0-rc0    #5951   +/-   ##
==============================================
  Coverage               ?   99.66%           
==============================================
  Files                  ?      425           
  Lines                  ?    40462           
  Branches               ?        0           
==============================================
  Hits                   ?    40328           
  Misses                 ?      134           
  Partials               ?        0           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/PennyLaneAI/pennylane/pull/5951?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PennyLaneAI).


Patch:
diff --git a/doc/releases/changelog-0.37.0.md b/doc/releases/changelog-0.37.0.md
index c07881f72..f5622eb58 100644
--- a/doc/releases/changelog-0.37.0.md
+++ b/doc/releases/changelog-0.37.0.md
@@ -471,6 +471,9 @@
 
 <h3>Bug fixes 🐛</h3>
 
+* Skip `Projector`-measurement tests on devices that do not support it.
+  [(#5951)](https://github.com/PennyLaneAI/pennylane/pull/5951)
+
 * The `default.tensor` device now preserves the order of wires if the initial MPS is created from a dense state vector.
   [(#5892)](https://github.com/PennyLaneAI/pennylane/pull/5892)
 


Test patch:
diff --git a/pennylane/devices/tests/test_return_system.py b/pennylane/devices/tests/test_return_system.py
index 16d863561..ed0aec266 100644
--- a/pennylane/devices/tests/test_return_system.py
+++ b/pennylane/devices/tests/test_return_system.py
@@ -39,6 +39,9 @@ class TestIntegrationMultipleReturns:
         n_wires = 2
         dev = device(n_wires)
 
+        if hasattr(dev, "observables") and "Projector" not in dev.observables:
+            pytest.skip("Skipped because device does not support the Projector observable.")
+
         obs1 = qml.Projector([0], wires=0)
         obs2 = qml.Z(1)
         func = qubit_ansatz
@@ -59,9 +62,13 @@ class TestIntegrationMultipleReturns:
 
     def test_multiple_var(self, device):
         """Return multiple vars."""
+
         n_wires = 2
         dev = device(n_wires)
 
+        if hasattr(dev, "observables") and "Projector" not in dev.observables:
+            pytest.skip("Skipped because device does not support the Projector observable.")
+
         obs1 = qml.Projector([0], wires=0)
         obs2 = qml.Z(1)
         func = qubit_ansatz