-
Notifications
You must be signed in to change notification settings - Fork 316
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
better test coverage for internal modules #146
Conversation
226e8d0
to
2a8195a
Compare
abc8202
to
f4da621
Compare
5ac843b
to
6f712e1
Compare
don't use six.print_ - not needed on py2.6 sort imports in conventional way
make the test with different keys, messages and nonces reproducible use all the curves/generators defined in the test (not only P-192)
use pytest.parameterize to execute the Known-Answer Tests for the NIST P-256 curve use a bit more sane formatting for the messages in the tests
use hypothesis (and larger numbers) for testing the inverse_mod function
make the jacobi test into a hypothesis test increase the range tested add test to verify factorization, since it's used in the jacobi test
extend the testing for large primes with hypothesis use pytest.parametrize to test with small primes
move sanity checks for gcd() to unittest add hypothesis tests for gcd
the function is just a wrapper around pow() builtin, so don't use it, mark it deprecated, exclude from coverage (as we're not testing it)
add hypothesis test to lcm
6f712e1
to
dc381a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the tests sound a bit redundant, when all you are doing is testing if the math library works correctly, but besides that I see no issues with this PR.
src/ecdsa/test_numbertheory.py
Outdated
"Hypothesis 2.0.0 can't be made tolerant of hard to " | ||
"meet requirements (like `is_prime()`)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really sure I understand what this means, might be clarified, for people not too familiar with hypothesis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is, what is the actual issue ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when you select random integers, few of them will be primes, so the test case generation takes a lot of time; hypothesis doesn't like it when it takes few seconds
with new versions, we can disable those checks, but with old (the oldest supported on py2.6) we can't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pleas mention that the issue is a time issue then.
yes, the maths library that is part of this package... there is no |
There is math.gcd() but lcm() is indeed not there, although lcm() is so trivial to create once you have gcd(). I thought lcm() was also there but now that I look at it, it turns out I also implemented it recently for some test elsewhere :-D |
Indeed, but not in older versions:
probably we can use it to speed up newer versions, but the old code needs to remain ok, thanks for the review! |
preparation for #127
make the test coverage more readable and make it use pytest or unittest asserts for checks
where possible, also use pytest parametrisation or hypothesis