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

Set test backend in conftest #407

Merged
merged 7 commits into from
May 6, 2021
Merged

Set test backend in conftest #407

merged 7 commits into from
May 6, 2021

Conversation

stavros11
Copy link
Member

Currently we use the following three lines

original_backend = qibo.get_backend()
qibo.set_backend(backend)
# ... test code here ...
qibo.set_backend(original_backend)

in every test that runs with all different backends. This PR creates a pytest fixture that does this manipulation through the conftest.py so that we don't have to include the above lines in every test and avoid code repetition.

@stavros11 stavros11 requested a review from scarrazza May 5, 2021 19:39
@codecov
Copy link

codecov bot commented May 5, 2021

Codecov Report

Merging #407 (c1a4b00) into movetests (8aca616) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##           movetests      #407    +/-   ##
============================================
  Coverage     100.00%   100.00%            
============================================
  Files             79        79            
  Lines          12225     11397   -828     
============================================
- Hits           12225     11397   -828     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/qibo/tests/test_abstract_circuit_qasm.py 100.00% <ø> (ø)
src/qibo/tests/test_backends_matrices.py 100.00% <ø> (ø)
src/qibo/tests/test_cirq.py 100.00% <ø> (ø)
src/qibo/tests/test_core_circuit_noise.py 100.00% <ø> (ø)
src/qibo/tests/test_core_distcircuit.py 100.00% <ø> (ø)
src/qibo/tests/test_core_distcircuit_execution.py 100.00% <ø> (ø)
src/qibo/tests/test_core_distutils.py 100.00% <ø> (ø)
src/qibo/tests/test_core_fusion.py 100.00% <ø> (ø)
src/qibo/tests/test_core_gates_controlled.py 100.00% <ø> (ø)
src/qibo/tests/test_core_gates_density_matrix.py 100.00% <ø> (ø)
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8aca616...c1a4b00. Read the comment docs.

Copy link
Member

@scarrazza scarrazza left a comment

Choose a reason for hiding this comment

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

@stavros11 thanks a lot, I was thinking about that when looking at the other pull request.

I have just a comment, I believe there must be a way to drop the backend argument of each test and use a decorator instead. However, this might be slightly complicated, so I believe we can merge this PR as it is.

@scarrazza scarrazza merged commit 268f744 into movetests May 6, 2021
@stavros11 stavros11 deleted the testsbackend branch June 22, 2021 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants