Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Last active August 1, 2020 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinThoma/57afc0cb805cdc13419f16259deb17be to your computer and use it in GitHub Desktop.
Save MartinThoma/57afc0cb805cdc13419f16259deb17be to your computer and use it in GitHub Desktop.
# 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