Skip to content

Moved rigetti integration test logic to higher level conftest.py file… #6328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 27, 2023

Conversation

nafaynajam
Copy link
Contributor

… and included slow marker logic.

@nafaynajam nafaynajam requested review from vtomole, cduck and a team as code owners October 25, 2023 12:27
@CirqBot CirqBot added the size: M 50< lines changed <250 label Oct 25, 2023
@nafaynajam
Copy link
Contributor Author

@pavoljuhas Created this pull request for issue #6211 . This is my first pull request, if I have made any mistake in the process kindly guide me.

Define them in the correct section.
Also clean up duplicate marker definition.
@pavoljuhas
Copy link
Collaborator

@nafaynajam - thank you for contributing, I will do the review later today.

@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1549785) 97.89% compared to head (7513d44) 97.89%.

❗ Current head 7513d44 differs from pull request most recent head d246b4c. Consider uploading reports for the commit d246b4c to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6328   +/-   ##
=======================================
  Coverage   97.89%   97.89%           
=======================================
  Files        1108     1108           
  Lines       96210    96204    -6     
=======================================
- Hits        94186    94182    -4     
+ Misses       2024     2022    -2     
Files Coverage Δ
cirq-rigetti/cirq_rigetti/conftest.py 94.38% <ø> (-0.13%) ⬇️
conftest.py 100.00% <100.00%> (ø)
dev_tools/conftest.py 87.23% <ø> (-1.48%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

These are already specified in dev_tools/requirements/deps/.
Iterate over test items once rather than 3 times.
Allow checking of our custom test selection with `pytest --co -m skip`.
Otherwise let the mark expression fully control what tests are selected.
Comment on lines 30 to 32
config.addinivalue_line("markers", "slow: mark tests as slow")
config.addinivalue_line("markers", "weekly: mark tests as run only by weekly automation")
config.addinivalue_line("markers", "rigetti_integration: tests that connect to Quil compiler or QVM.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary after adding mark definitions to pyproject.toml.

Comment on lines 39 to 40
skip_slow_marker = pytest.mark.skip(reason='slow marker not selected')
# do not skip slow tests if --enable-slow-tests is passed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically conftest.py in subdirectories should have configurations relevant for that directory tree only.
The intent here is to have extra pytest options and test selection logic at one place.
As these are global settings it is better to move this to the top-level conftest.py.

Comment on lines 47 to 48
if config.getoption('--rigetti-integration'):
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early return here will also enable tests with the weekly mark, because their deselection happens later on.

pyproject.toml Outdated
@@ -4,6 +4,9 @@ target_version = ['py39', 'py310', 'py311']
skip-string-normalization = true
skip-magic-trailing-comma = true

[tool.pytest]
markers = ["rigetti_integration: tests that connect to Quil compiler or QVM.", "slow: mark tests as slow", "weekly: mark tests as run only by weekly automation"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the [tool.pytest.ini_options] section below.
Use pytest --markers to check if the extra marks are available.

Also the list should be formatted as one item per line for a better readability.

requirements.txt Outdated
@@ -0,0 +1,2 @@
pytest~=7.4.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is unnecessary, dependencies are already specified under dev_tools/requirements.

Copy link
Collaborator

@pavoljuhas pavoljuhas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see inline comments. I have got some ideas for improvement,
which I pushed as extra commits.

Please take a look and let me know if the updated code looks ok.

As a general suggestion for git workflows, it is a good practice to do the
PR work in a new branch with some descriptive name (say unify-test-selection-logic).
The master branch can be then kept in sync with the main repo.

@pavoljuhas
Copy link
Collaborator

BTW, I have verified the default test selection and the --rigetti-integration option behave as before.

@pavoljuhas
Copy link
Collaborator

Partial fix of #6211

Exclude a few conftest.py lines from coverage enforcement.
Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks a lot Nafay and Pavol!

@pavoljuhas pavoljuhas enabled auto-merge (squash) October 27, 2023 20:10
@pavoljuhas pavoljuhas merged commit 1eced48 into quantumlib:master Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants