import unittest
import io
import re
from unittest import mock
import math
import copy
import inspect
import student_X as main #Replace student_X with your filename 
    
    
    
 

class GetAgeTests(unittest.TestCase):

    def test_default_case(self):
        jackelope = main.Car(1991, 'beige', 'Corolla')
        tdi = main.Car(2010, 'gray', 'Jetta')
        
        function = main.Car.get_age
        
        test = False
        try:
            incorrect = ""
            result = function.__doc__
            result = result.strip()
            test =  result != incorrect
        except:
            pass
        message = "No Docstring."
        self.assertTrue(test, message)

        
        
        inputs = (jackelope, 2023)

        tested_inputs = inputs #change this if you need to test specific inputs

        #expected answers
        correct_inputs = inputs
        correct_result = 32
        correct_printed = ""

        #run the test
        with mock.patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            if isinstance(inputs, tuple):
                result = function(*inputs)
            else:
                result = function(inputs)
        printed_output = fake_stdout.getvalue().strip()

        #this is a cheat.  Take this out for later ones!
        #correct_result = result


        test = correct_printed == printed_output
        message = "Shouldn't print anything."
        self.assertTrue(test, message)
        test = result == correct_result
        message = "Doesn't work on a beige Corolla from 1991."
        self.assertTrue(test, message)
        test = tested_inputs == correct_inputs
        message = "Modifies the inputs."
        self.assertTrue(test, message)

        
        
        inputs = (tdi, 2023)

        tested_inputs = inputs #change this if you need to test specific inputs

        #expected answers
        correct_inputs = inputs
        correct_result = 13
        correct_printed = ""

        #run the test
        with mock.patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            if isinstance(inputs, tuple):
                result = function(*inputs)
            else:
                result = function(inputs)
        printed_output = fake_stdout.getvalue().strip()

        #this is a cheat.  Take this out for later ones!
        #correct_result = result


        test = correct_printed == printed_output
        message = "Shouldn't print anything."
        self.assertTrue(test, message)
        test = result == correct_result
        message = "Doesn't work on my hidden car."
        self.assertTrue(test, message)
        test = tested_inputs == correct_inputs
        message = "Modifies the inputs."
        self.assertTrue(test, message)



        
        
if __name__ == "__main__":
    tests = GetAgeTests()
    tests.test_default_case()