Missing tests for `gen_pauli_x` and `gen_pauli_z`
Closed this issue · 6 comments
Related to #478
Tests for these functions are missing from toqito/matrices/tests
Tests in matrices/tests |
Defined functions in matrices/ |
---|---|
Interestingly enough, both these functions are not flagged as uncovered by pytest
.
This issue is to find where the tests for these functions are or add files to test them. If it's the latter, need to figure out why pytest
is not flagging these.
@vprusso Looking at the commit history for both functions, I don't think the tests for these functions were added. Wanted to double-check with you as to what might have happened. Maybe the tests got lost in other modules?
Looking through the old commits, I don't see the tests in the previous tests
directory.
We changed the directory in #257 and if I look at another PR #255 merged before the restructured directory, the tests don't exist where we expect them to be.
https://github.com/vprusso/toqito/tree/63c86059f06f994e23be93f3a4626c0b1717b464/tests/test_matrices
Maybe this is also a pytest
issue as it does not flag the uncovered lines in addition to missing tests.
Maybe pytest
thinks the lines below cover the expected output of other functions.
toqito/toqito/matrices/gen_pauli.py
Lines 74 to 75 in eb58207
Hmm, so I think these are covered because there is a test for gen_pauli
which calls both of these functions. As there isn't any branching in either, testing them via that one function should be all that is required to have them covered from that.
But yes, having a few specific tests for them explicitly might be a good idea, just to be more thorough and explicit.
To close this issue after #478 is merged, in the folder toqito/matrices/tests
, add a file labeled test_gen_pauli_x
and another labeled test_gen_pauli_z
for testing the functions via pytest
.
List of all possible tests:
- Verify the shape of the matrices is what we expect
- Verify the expected output is what we expect for a bunch of different values for
dim
.
It might also be better to use the parameterized option in pytest to consolidate a bunch of identical tests.
https://docs.pytest.org/en/7.3.x/how-to/parametrize.html
Here's an example test in toqito
where pytest verifies an array output.
toqito/toqito/perms/tests/test_antisymmetric_projection.py
Lines 19 to 32 in eb58207