def test002_getUserFloatSendsCorrectPrompt(self): from main import getUserFloat expected_prompt = "HELLO" expected_response = "1.7" self.input_response_list = [expected_response] actual_response = getUserFloat(expected_prompt) self.assertEqual(expected_prompt, self.input_given_prompt) return
def test006_getUserFloatIgnoresBlankLines(self): from main import getUserFloat expected_prompt = "HELLO" expected_response = "10" self.input_response_list = ["", "0.0", "hello", "-1.7", "\n", " \t\n" + expected_response + " \t\n"] actual_response = getUserFloat(expected_prompt) self.assertTrue(type(actual_response) is float) self.assertEqual(10.0, actual_response) return
def test004_getUserFloatStripsWhitespace(self): from main import getUserFloat expected_prompt = "HELLO" expected_response = "1.7" self.input_response_list = [" \t\n" + expected_response + " \t\n"] actual_response = getUserFloat(expected_prompt) self.assertTrue(type(actual_response) is float) self.assertEqual(float(expected_response), actual_response) return
def test003_getUserFloatGetsInput(self): from main import getUserFloat expected_prompt = "HELLO" expected_response = "1" self.input_response_list = [expected_response] actual_response = getUserFloat(expected_prompt) self.assertTrue(type(actual_response) is float) self.assertEqual(1.0, actual_response) return
def test005_getUserFloatBadInputCheck(self): from main import getUserFloat expected_prompt = "HELLO" expected_response = "7.6" self.input_response_list = ["zero", "-1.7", "0", "0.0", "-20.0", "", "sixteen", expected_response] actual_response = getUserFloat(expected_prompt) self.assertTrue(type(actual_response) is float) self.assertEqual(float(expected_response), actual_response, 'Your repsonse (%s) did not equal the expected response (%s)' % (actual_response, expected_response)) return