Skip to content

Commit

Permalink
Ignore _about.py in pytest coverage (unitaryfund#2379)
Browse files Browse the repository at this point in the history
* ignore about.py

* correct typo in mitiq/pec/representations/optimal.py

* test about func

* remove -rP line from makefile

* use capsys

* add back removed blankline
  • Loading branch information
purva-thakre authored Jul 3, 2024
1 parent 6250c94 commit e61c058
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[run]
omit =
*/tests/*
mitiq/_about.py


[report]
# Regexes for lines to exclude from consideration
Expand Down
4 changes: 2 additions & 2 deletions mitiq/_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def about() -> None:
pyquil_version = "Not installed"

try:
from qiskit import __qiskit_version__ # pragma: no cover
from qiskit import __qiskit_version__

qiskit_version = __qiskit_version__["qiskit"] # pragma: no cover
qiskit_version = __qiskit_version__["qiskit"]
except ImportError:
qiskit_version = "Not installed"

Expand Down
2 changes: 1 addition & 1 deletion mitiq/pec/representations/optimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def find_optimal_representation(
" which are initialized with a numerical superoperator matrix."
)
else:
raise err # pragma no cover
raise err # pragma: no cover

# Run numerical optimization problem
quasi_prob_dist = minimize_one_norm(
Expand Down
16 changes: 16 additions & 0 deletions mitiq/tests/test_about.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) Unitary Fund
#
# This source code is licensed under the GPL license (v3) found in the
# LICENSE file in the root directory of this source tree.

"""Tests for mitiq.about()."""

import mitiq


def test_result_and_stdout(capsys):
mitiq.about()
captured = capsys.readouterr()
assert captured.out.startswith(
"\nMitiq: A Python toolkit for implementing"
)

0 comments on commit e61c058

Please sign in to comment.