def test_sum_series(): """Verify some simple behaviors of s.sum_series(...)""" for i in range(25): assert s.sum_series(0, i, i + 1) == i assert s.sum_series(1, i + 1000, i) == i assert s.sum_series(i, 1, 1) == s.fibonacci(i + 1) assert s.sum_series(i, 3, 4) == s.lucas(i + 2)
def test_sum_series_555(): """Test sum_series with n of 5, first of 5, second of 5. Should return 25 """ from series import sum_series assert sum_series(5, 5, 5) == 25
def test_sum_series_102030(): """Test sum_series with n of 10, first of 20, second of 30. Should return 1410 """ from series import sum_series assert sum_series(10, 20, 30) == 1440
def test_sum_series_501(): """Test sum_series with n of 5, first of 0, second of 1. Should return 3 """ from series import sum_series assert sum_series(5, 0, 1) == 3
def test_sum_series_521(): """Test sum_series with n of 5, first of 2, second of 1. Should return 7 """ from series import sum_series assert sum_series(5, 2, 1) == 7
def test_sum_series(): assert(series.sum_series(0, 10, 20) == 10) assert(series.sum_series(1, 10, 20) == 20) assert(series.sum_series(2, 10, 20) == 30) assert(series.sum_series(3, 10, 20) == 50) assert(series.sum_series(4, 10, 20) == 80) assert(series.sum_series(5, 10, 20) == 130) assert(series.sum_series(6, 10, 20) == 210) assert(series.sum_series(7, 10, 20) == 340)
def test_sum_series(): assert (series.sum_series(0, 10, 20) == 10) assert (series.sum_series(1, 10, 20) == 20) assert (series.sum_series(2, 10, 20) == 30) assert (series.sum_series(3, 10, 20) == 50) assert (series.sum_series(4, 10, 20) == 80) assert (series.sum_series(5, 10, 20) == 130) assert (series.sum_series(6, 10, 20) == 210) assert (series.sum_series(7, 10, 20) == 340)
def test_fibo_and_sumseries(): # Fibonacci list of paired inputs and expected outputs. fiboInOut = [(0, 0), (1, 1), (2, 1), (3, 2), (4, 3), (5, 5), (6, 8), (7, 13), (8, 21), (9, 34), (10, 55)] # Checking actual results with expected results from fiboInOut list for n, result in fiboInOut: assert fibonacci(n) == result assert sum_series(n) == result
def test_lucas_and_sumseries(): # Lucas list of paired inputs and expected outputs. lucasInOut = [(0, 2), (1, 1), (2, 3), (3, 4), (4, 7), (5, 11), (6, 18), (7, 29), (8, 47), (9, 76), (10, 123)] # Checking actual results with expected results from lucasInOut list for n, result in lucasInOut: assert lucas(n) == result assert sum_series(n, 2, 1) == result
def test_fibonacci(): u""" Ensure the first 12 values returned by fibonacci() equal a known source. Also ensures the first 12 values returned by sum_series() with the default arguments matches the output. """ for input_, output in fibonacci_vals: assert series.fibonacci(input_) == output assert series.sum_series(input_) == output
def test_sum_series(): # 1 point for passing the four tests below assert(series.sum_series(0, 10, 20) == 10) assert(series.sum_series(1, 10, 20) == 20) assert(series.sum_series(2, 10, 20) == 30) assert(series.sum_series(3, 10, 20) == 50) # 1 point for passing the four tests below assert(series.sum_series(4, 10, 20) == 80) assert(series.sum_series(5, 10, 20) == 130) assert(series.sum_series(6, 10, 20) == 210) assert(series.sum_series(7, 10, 20) == 340)
def test_sum_series_fib2(): actual = sum_series(4, 0, 1) expected = 2 assert actual == expected # def test_sum_series_fib3(): # actual = sum_series(8, 0, 1) # expected = 13 # assert actual == expected
def test_lucas_vals(): u""" Ensure the first 12 values returned by lucas() equal a known source. Also ensures the first 12 values returned by sum_series() called with iniital values equivalent to the first two values in lucas() matches the output. """ for input_, output in lucas_vals: assert series.lucas(input_) == output assert series.sum_series(input_, 2, 1) == output
def test_bad_inputs(): u""" Verify that fibonacci(), lucas(), and sum_series() catch all inputs that are not non-negative integers. """ for badval in [3.14, 'a', []]: with pytest.raises(ValueError): fibonacci_result = series.fibonacci(badval) lucas_result = series.lucas(badval) sum_series_result = series.sum_series(badval)
def test_sum_series(): # sum_series assert sum_series(1) == 1 assert sum_series(5) == 5 assert sum_series(6) == 8 assert sum_series(0, 2, 1) == 2 assert sum_series(5, 2, 1) == 11 assert sum_series(5, 3, 4) == 29
def test_6(self): self.assertEqual(sum_series(2, 2, 1), 3)
def test_both_n_at_1_4_9(): actual = sum_series(1, 4, 9) expected = 4 assert actual == expected
def test_sum_series(): for i in range(7): assert sum_series(i) == fibonacci(i) assert sum_series(i, 2, 1) == lucas(i)
def test_sum_series_is_fib(): """Verify that s.sum_series(n) without optional arguments is s.fibonacci(n)""" for i in range(25): assert s.sum_series(i) == s.fibonacci(i)
def test_sum_series2(n, one, two, result): from series import sum_series assert sum_series(n, one, two) == result
def test_sum(): # Check sum_series function, test list using default (fibonacci) values for i in range(1, len(fib_values)+1): assert sum_series(i) == fib_values[i-1]
def test_sum_series(n, result, a, b): """Assert nth number in fibonacci series if no optional args.""" from series import sum_series assert sum_series(n, a, b) == result
def test_sum_series(): assert (series.sum_series(9) == 34) assert (series.sum_series(9, 2, 1) == 76) assert (series.sum_series(9, 2, 4) == 178)
def test_sum_series(args, result): from series import sum_series assert sum_series(*args) == result
def test_sum_series_fib_25(): from series import sum_series assert sum_series(25) == 46368
def test_sum_2_1(): # Check sum_series function, test list using 2,1 (sum_series) values for i in range(1, len(lucas_values)+1): assert sum_series(i, 2, 1) == lucas_values[i-1]
def test_sum_series1(n, result): from series import sum_series assert sum_series(n) == result
def test_neg(): # Check functions with negative n values. assert sum_series(-1, 2, 1) is None assert fibonacci(-4) is None assert lucas(0) is None
def test_sum_series_lucas(n, result): """Test function `sum_series' outputs correct values for the Lucas sequence.""" from series import sum_series assert sum_series(n, 2, 1) == result
def test_both_n_at_1_0_1(): actual = sum_series(1, 0, 1) expected = 0 assert actual == expected
def test_sum_series_is_lucas(): """Verify that s.sum_series(n,2,1) with optional arguments 2, 1 is s.lucas(n)#""" for i in range(25): assert s.sum_series(i, 2, 1) == s.lucas(i)
def test_both_n_at_10_0_1(): actual = sum_series(10, 0, 1) expected = 34 assert actual == expected
def test_my_series(self): test_vals = (3, 2, 1) expected = 4 actual = sum_series(*test_vals) self.assertEquals(expected, actual)
def test_both_n_at_6_2_1(): actual = sum_series(6, 2, 1) expected = 11 assert actual == expected
def test_both_n_at_10_4_9(): actual = sum_series(10, 4, 9) expected = 390 assert actual == expected
def test_fibonacci(): # fibonacci assert fibonacci(0) == 0 assert fibonacci(5) == 5 assert sum_series(0) == 0
def test_both_n_at_6_0_1(): actual = sum_series(6, 0, 1) expected = 5 assert actual == expected
def test_sum(n, x, y, result): from series import sum_series assert sum_series(n, x, y) == result
def test_both_n_at_1_2_1(): actual = sum_series(1, 2, 1) expected = 2 assert actual == expected
def test_sum_series_other_5(): from series import sum_series assert sum_series(5, 5, 3) == 19
def test_both_n_at_10_2_1(): actual = sum_series(10, 2, 1) expected = 76 assert actual == expected
def test_sum_series_luc_1(): from series import sum_series assert sum_series(1, 2, 1) == 2
def test_5(self): self.assertEqual(sum_series(3), 2)
def test_sum_series_fib_2(): from series import sum_series assert sum_series(2) == 1
def test_sum_series_other_3(): from series import sum_series assert sum_series(3, 5, 3) == 8
def test_sum_series_other_2(): from series import sum_series assert sum_series(2, 5, 3) == 3
def test_sum_series_luc_25(): from series import sum_series assert sum_series(25, 2, 1) == 103682
def test_sum_series_luc_3(): from series import sum_series assert sum_series(3, 2, 1) == 3
def test_sum_series_fib_1(): from series import sum_series assert sum_series(1) == 0
def test_sum_series(n, val1, val2, result): """Test sum_series function against Lucas, Fibonacci and custom values.""" from series import sum_series assert sum_series(n, val1, val2) == result
def test_sum_series_other_1(): from series import sum_series assert sum_series(1, 5, 3) == 5
def test_sum_series(case, x, y, result): """Test the sum of a series given it's 1st and 2nd cases.""" from series import sum_series assert sum_series(case, x, y) == result
def test_sum_series_luc_2(): from series import sum_series assert sum_series(2, 2, 1) == 1
def test_sum_series(n, first, second, result): import series assert series.sum_series(n, first, second) == result
def test_sum_series_fib_3(): from series import sum_series assert sum_series(3) == 1
def test_sum_series_partial_2(n, result): import series assert series.sum_series(n, 2) == result
def test_sum_series(n, num1, num2, result): """Test sum_series method to see which series is selected.""" from series import sum_series assert sum_series(n, num1, num2) == result
def test_sum_series_fibonacci(n, result): """Test function `sum_series' outputs correct values for the Fibonacci sequence (i.e., the case where optional parameters are not supplied).""" from series import sum_series assert sum_series(n) == result