-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to sphinx-alt-text-validator (#2502)
This PR creates tests for the `sphinx-alt-text-validator` and recovers the tests of the `nb-tester` in CI. See #2445 (review) and #2425 (comment) Example of the test running: https://github.com/Qiskit/documentation/actions/runs/12390997779/job/34587197281?pr=2502#step:22:1
- Loading branch information
1 parent
eda1554
commit ab6c4ea
Showing
5 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,3 +86,6 @@ jobs: | |
"To fix, install tox and run `tox -e fix`." | ||
) | ||
sys.exit(1) | ||
- name: Test packages | ||
run: tox -e tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from sphinx_alt_text_validator.verify_images import ( validate_images ) | ||
|
||
EXAMPLE_RST_WITH_IMAGES = """\ | ||
.. image:: /example_image/example1.png | ||
:width: 400 | ||
.. image:: /example_image/example2.png | ||
:alt: Example | ||
.. image:: /example_image/example3.png | ||
.. plot:: | ||
:include-source: | ||
from numpy import sqrt | ||
from qiskit.quantum_info import Statevector | ||
sv=Statevector([1/sqrt(2), 0, 0, -1/sqrt(2)]) | ||
sv.draw(output='hinton') | ||
.. plot:: | ||
:alt: Example | ||
:include-source: | ||
from numpy import sqrt | ||
from qiskit.quantum_info import Statevector | ||
sv=Statevector([1/sqrt(2), 0, 0, -1/sqrt(2)]) | ||
sv.draw(output='hinton') | ||
.. image:: /example_image/example4.png | ||
.. plot:: | ||
:include-source: | ||
:nofigs: | ||
from numpy import sqrt | ||
from qiskit.quantum_info import Statevector | ||
sv=Statevector([1/sqrt(2), 0, 0, -1/sqrt(2)]) | ||
""" | ||
|
||
|
||
def test_validate_image(): | ||
invalid_images = validate_images(EXAMPLE_RST_WITH_IMAGES) | ||
assert invalid_images == [ | ||
'- Error in line 1: .. image:: /example_image/example1.png', | ||
'- Error in line 7: .. image:: /example_image/example3.png', | ||
'- Error in line 9: .. plot::', | ||
'- Error in line 24: .. image:: /example_image/example4.png', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters