From 38dfcd28b5f2fb19bae130a942466d73933e072f Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Thu, 14 Jul 2022 12:54:24 +0530 Subject: [PATCH] fix: test failures (#6250) 1. Incorrect function was being imported from the module 2. Testing for exception was not done correctly --- maths/miller_rabin.py | 6 +++--- maths/prime_check.py | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/maths/miller_rabin.py b/maths/miller_rabin.py index d35e54858..b4dfed129 100644 --- a/maths/miller_rabin.py +++ b/maths/miller_rabin.py @@ -8,9 +8,9 @@ from .binary_exp_mod import bin_exp_mod # if it's not a prime, the chance of it returning true is at most 1/4**prec def is_prime_big(n, prec=1000): """ - >>> from maths.prime_check import prime_check - >>> # all(is_prime_big(i) == prime_check(i) for i in range(1000)) # 3.45s - >>> all(is_prime_big(i) == prime_check(i) for i in range(256)) + >>> from maths.prime_check import is_prime + >>> # all(is_prime_big(i) == is_prime(i) for i in range(1000)) # 3.45s + >>> all(is_prime_big(i) == is_prime(i) for i in range(256)) True """ if n < 2: diff --git a/maths/prime_check.py b/maths/prime_check.py index 6af5a75c2..80ab8bc5d 100644 --- a/maths/prime_check.py +++ b/maths/prime_check.py @@ -62,10 +62,8 @@ class Test(unittest.TestCase): self.assertTrue(is_prime(29)) def test_not_primes(self): - self.assertFalse( - is_prime(-19), - "Negative numbers are excluded by definition of prime numbers.", - ) + with self.assertRaises(AssertionError): + is_prime(-19) self.assertFalse( is_prime(0), "Zero doesn't have any positive factors, primes must have exactly two.",