Last active
August 1, 2020 05:55
-
-
Save MartinThoma/57afc0cb805cdc13419f16259deb17be to your computer and use it in GitHub Desktop.
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
# Third party | |
import hypothesis.strategies as s | |
from hypothesis import given | |
# First party | |
from factorize import factorize | |
@given(s.integers(min_value=-(10 ** 6), max_value=10 ** 6)) | |
def test_factorize_multiplication_property(n): | |
"""The product of the integers returned by factorize(n) needs to be n.""" | |
factors = factorize(n) | |
product = 1 | |
for factor in factors: | |
product *= factor | |
assert product == n, f"factorize({n}) returned {factors}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment