def prompt_for_retirement_age(): age = prompt_user("Please enter your age", '^[0-9]+$') salary = prompt_user("Please enter your salary as a number", '^[0-9]+$') saved = prompt_user( "Please enter the percantage of your salary that you save", '\d*\.\d+|\d+') goal = prompt_user( "Please enter how much money you need to retire as a number", '^[0-9]+$') try: return Retirement(int(age), int(salary), float(saved), int(goal)) except RuntimeError as e: print(e) return ''
def test_Retirement_saved_raises_exception_on_equal_0_perecent_float_args(): with pytest.raises(RuntimeError): Retirement(32, 45000, 0.0, 50000)
def test_Retirement_goal_raises_exception_on_non_int_args_for_float(): with pytest.raises(TypeError): Retirement(32, 45000, 5.0, 50000.25)
def test_Retirement_saved_raises_exception_on_negative_float_args(): with pytest.raises(RuntimeError): Retirement(32, 45000, -15.2, 50000)
def test_Retirement_saved_raises_exception_on_over_100_perecent_float_args(): with pytest.raises(RuntimeError): Retirement(32, 45000, 101.5, 50000)
def retirement(age, salary, percentage, goal): Retirement.retirement(age, salary, percentage, goal) return 'Request Accepted'
def test_Retirement_saved_raises_exception_on_non_float_args_for_None(): with pytest.raises(TypeError): Retirement(32, 45000, None, 50000)
def test_Retirement_salary_raises_exception_on_non_int_args_for_None(): with pytest.raises(TypeError): Retirement(32, None, 5.0, 50000)
def test_Retirement_salary_raises_exception_on_zero_int_args(): with pytest.raises(RuntimeError): Retirement(32, 0, 5.0, 50000)
def test_Retirement_age_raises_exception_on_too_old_int_args(): with pytest.raises(RuntimeError): Retirement(100, 45000, 5.0, 50000)
def test_Retirement_age_raises_exception_on_non_int_args_for_str(): with pytest.raises(TypeError): Retirement("age", 45000, 5.0, 50000)
def test_Retirement_age_raises_exception_on_negative_int_args(): with pytest.raises(RuntimeError): Retirement(-45, 45000, 5.0, 50000)
def test_Retirement_returns_string_argument(): assert isinstance(Retirement(32, 45000, 5.0, 500000), str), 'Test Failed: Function must return a string'
def test_Retirement_goal_raises_exception_on_negative_int_args(): with pytest.raises(RuntimeError): Retirement(32, 45000, 5.0, -5)
print("Your BMI is " + BMI.BMI(height_feet, height_inches, weight)) elif int(choice) == 2: print("What is your current age?") age = input(">") print("What is your annual salary?") salary = input(">") print( "What percentage of your salary do you save? (Input as a percentage not a decimal)" ) saving = input(">") print("How much money do you want to have by the time you retire?") goal = input(">") print("Retirement age:\n", Retirement.retirement(age, salary, saving, goal)) elif int(choice) == 3: print("Input the first point. (Use the format (x, y))") point1 = input(">") print("Input the second point. (Use the format (x, y))") point2 = input(">") point1 = tuple(point1[1:-1].split(',')) point2 = tuple(point2[1:-1].split(',')) print(ShortestDistance.shortest_distance(point1, point2)) elif int(choice) == 4: print("What was the total dinner amount without the tip?") dinner = input(">")
def test_Retirement_saved_raises_exception_on_non_float_args_for_str(): with pytest.raises(TypeError): Retirement(32, 45000, 'annual salary', 50000)
print("Your BMI is " + BMI.BMI(height_feet, height_inches, weight)) elif int(choice) == 2: print("What is your current age?") age = input(">") print("What is your annual salary?") salary = input(">") print( "What percentage of your salary do you save? (Input as a percentage not a decimal)" ) saving = input(">") print("How much money do you want to have by the time you retire?") goal = input(">") print("Retirement age:\n", Retirement.retirement(age, salary, saving, goal)) elif int(choice) == 3: print("Input the first point. (Use the format (x, y))") point1 = input(">") print("Input the second point. (Use the format (x, y))") point2 = input(">") point1 = tuple(point1[1:-1].split(',')) point2 = tuple(point2[1:-1].split(',')) print(ShortestDistance.shortest_distance(point1, point2)) elif int(choice) == 4: print("What was the total dinner amount without the tip?") dinner = input(">")
def retrieveRETIREMENT(): return render_template('Results.html', entries=Retirement.retrieveEntry())