Skip to content
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

Replace assert in tests with unittest methods #10136

Merged
merged 2 commits into from
May 22, 2023

Conversation

Cryoris
Copy link
Contributor

@Cryoris Cryoris commented May 22, 2023

Summary

Mainly a follow-up to #8695, where we noticed some plain assert statements used instead of the appropriate unittest methods. Also replaces those in some other tests and removes a dangling commented assert line.

Details and comments

@Cryoris Cryoris requested review from a team, ikkoham, woodsp-ibm and ElePT as code owners May 22, 2023 07:45
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Cryoris
  • @ElePT
  • @Qiskit/terra-core
  • @ajavadia
  • @ikkoham
  • @woodsp-ibm

@Cryoris Cryoris added Changelog: None Do not include in changelog type: qa Issues and PRs that relate to testing and code quality labels May 22, 2023
@coveralls
Copy link

coveralls commented May 22, 2023

Pull Request Test Coverage Report for Build 5045808939

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 23 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.002%) to 85.928%

Files with Coverage Reduction New Missed Lines %
qiskit/extensions/quantum_initializer/squ.py 2 80.0%
crates/qasm2/src/lex.rs 3 91.39%
qiskit/circuit/classicalfunction/boolean_expression.py 6 0%
crates/qasm2/src/parse.rs 12 96.18%
Totals Coverage Status
Change from base Build 5030016914: -0.002%
Covered Lines: 71277
Relevant Lines: 82950

💛 - Coveralls

ElePT
ElePT previously approved these changes May 22, 2023
Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

LGTM, I did not check extensively if there were other uses of assert outside of this PR, but I guess that we can open a new PR if we find them.

Comment on lines -57 to -58
from scipy.optimize import rosen
from qiskit.utils import algorithm_globals
Copy link
Contributor

Choose a reason for hiding this comment

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

These local imports looked strange to me too.

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

Thanks for tidying this up. There's just one place where I think the new method isn't quite right, but other than that, looks good to me.

test/python/algorithms/optimizers/test_umda.py Outdated Show resolved Hide resolved
@jakelishman jakelishman enabled auto-merge May 22, 2023 12:38
@jakelishman jakelishman added this pull request to the merge queue May 22, 2023
Merged via the queue into Qiskit:main with commit 17590b6 May 22, 2023
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request May 22, 2023
* Replace `assert` with unittest methods

* Update test/python/algorithms/optimizers/test_umda.py

Co-authored-by: Jake Lishman <[email protected]>

---------

Co-authored-by: Jake Lishman <[email protected]>
ElePT pushed a commit to ElePT/qiskit that referenced this pull request Jun 27, 2023
* Replace `assert` with unittest methods

* Update test/python/algorithms/optimizers/test_umda.py

Co-authored-by: Jake Lishman <[email protected]>

---------

Co-authored-by: Jake Lishman <[email protected]>
ElePT pushed a commit to ElePT/qiskit-algorithms-test that referenced this pull request Jul 17, 2023
* Replace `assert` with unittest methods

* Update test/python/algorithms/optimizers/test_umda.py

Co-authored-by: Jake Lishman <[email protected]>

---------

Co-authored-by: Jake Lishman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog type: qa Issues and PRs that relate to testing and code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants