text: #!/usr/bin/python3
  
  import unittest
  '''
  Problem 2: https://projecteuler.net/problem=2
  
  Each new term in the Fibonacci sequence is generated by adding the previous
  two terms. By starting with 1 and 2, the first 10 terms will be:
  
  1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
  
  By considering the terms in the Fibonacci sequence whose values do not exceed
  four million, find the sum of the even-valued terms.
  
  Correct answer: 4613732
  '''
  
  
  def sum_evens_fibonacci(limit):
      sum = 0
      a, b = 1, 2
  
      if(isinstance(limit, int) and limit > 0):
          while a < limit:
              if a % 2 == 0:
                  sum += a
              a, b = b, a + b
  
      return sum
  
  print("Sum: " + str(sum_evens_fibonacci(4*(10**6))))
  
  
  class SumEvenFibonacciNumbersTest(unittest.TestCase):
      def setup(self):
          pass
  
      def test_sum_of_even_fibonacci_below_10(self):
          self.assertEqual(sum_evens_fibonacci(10), 10)
  
      def test_passed_number_is_negative(self):
          self.assertEqual(sum_evens_fibonacci(-10), 0)
  
      def test_passed_number_is_string(self):
          self.assertFalse(sum_evens_fibonacci('10'))
  
      def test_passed_number_is_float(self):
          self.assertFalse(sum_evens_fibonacci(10.5))
  
      def test_passed_number_is_zero(self):
          self.assertFalse(sum_evens_fibonacci(0))
  
  if __name__ == '__main__':
      unittest.main()
  