Beispiel #1
0
 def test002_getUserFloatSendsCorrectPrompt(self):
     from gas_mileage 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
Beispiel #2
0
 def test004_getUserFloatStripsWhitespace(self):
     from gas_mileage 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
Beispiel #3
0
 def test003_getUserFloatGetsInput(self):
     from gas_mileage 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
Beispiel #4
0
 def test006_getUserFloatIgnoresBlankLines(self):
     from gas_mileage 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
Beispiel #5
0
 def test005_getUserFloatBadInputCheck(self):
     from gas_mileage 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