本文整理汇总了Python中source.main.Interface类的典型用法代码示例。如果您正苦于以下问题:Python Interface类的具体用法?Python Interface怎么用?Python Interface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Interface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_question_prev_function_ptr
def test_question_prev_function_ptr(self):
new_interface = Interface()
test_string1 = "How did a function ptr get here?"
result = new_interface.ask(test_string1)
result = new_interface.teach(get_quadrilateral_type)
result = new_interface.ask(test_string1)
self.assertEqual(result, "invalid")
示例2: test_fibonacci_digit
def test_fibonacci_digit(self):
'''
This function tests the interface for the fibonacci sequence.
'''
interface = Interface()
result = interface.ask("What is the 10 digit of fibonacci?")
self.assertEqual(result, 34)
示例3: test_set_user_name
def test_set_user_name(self):
'''
This function tests the interface for username recognition.
'''
interface = Interface()
result = interface.set_user("Dave")
self.assertEqual(result, "Hello, Dave.")
示例4: test_numberic_no_conversion
def test_numberic_no_conversion(self):
'''
This function tests the interface for incorrect unit conversion.
'''
interface = Interface()
result = interface.ask("Convert 1 meter to quadrillometers")
self.assertEqual(result, "Sorry, I can't convert that.")
示例5: test_current_directory
def test_current_directory(self):
'''
This function tests the interface for current directory retrieval.
'''
interface = Interface()
result = interface.ask("What directory is this using?")
self.assertEqual(result.lower(), os.getcwd().lower())
示例6: test_questions_keywords
def test_questions_keywords(self):
x = Interface()
self.assertEqual(x.ask(question="How ?"), "I don't know, please provide the answer")
self.assertEqual(x.ask(question="How ?"), "I don't know, please provide the answer")
self.assertEqual(x.ask(question="Where ?"), "I don't know, please provide the answer")
self.assertEqual(x.ask(question="Who ?"), "I don't know, please provide the answer")
self.assertEqual(x.ask(question="Why ?"), "I don't know, please provide the answer")
示例7: test_answer
def test_answer(self):
x = Interface()
start = time.clock()
val = x.correct("No respond")
proc_time = time.clock() - start
self.assertTrue(val)
self.assertLessEqual(proc_time, 0.5)
示例8: test_fileStatus_Dirty
def test_fileStatus_Dirty(self, mock_dirty, mock_untracked, mock_diff):
obj = Interface()
mock_diff.return_value = []
mock_dirty.return_value = True
mock_untracked.return_value = []
result = obj.ask('What is the status of <requirements.txt>?')
self.assertEqual(result, 'requirements.txt is a dirty repo')
示例9: test_ask_open_door
def test_ask_open_door(self):
new_interface = Interface()
start_time = time.clock()
result = new_interface.ask("Open the door hal!")
end_time = time.clock()
self.assertLess(end_time - start_time, .05)
self.assertEqual(result, "I'm afraid I can't do that " + getpass.getuser())
示例10: test_ask_who_let_dogs_out
def test_ask_who_let_dogs_out(self):
obj = Interface()
question = 'Who let the dogs out?'
result = obj.ask(question)
output_to_file(question, result)
self.assertEqual(result, getpass.getuser() + ' let the dogs out')
示例11: test_get_git_file_info_upToDate
def test_get_git_file_info_upToDate(self, mock_is_repo_dirty, mock_get_untracked_files, mock_get_diff_files):
obj = Interface()
mock_get_diff_files.return_value = []
mock_get_untracked_files.return_value = []
mock_is_repo_dirty.return_value = False
result = obj.ask('What is the status of <requirements.txt>?')
self.assertEqual(result, 'requirements.txt is up to date')
示例12: test_hello_valid
def test_hello_valid(self):
new_interface = Interface()
test_string1 = "Hello?"
result = new_interface.ask(test_string1)
user = getuser()
expected_result = ("Hello, I am " + user + "'s guide.")
self.assertEqual(result, expected_result)
示例13: test_open_door
def test_open_door(self):
new_interface = Interface()
test_string1 = "Open the door hal."
result = new_interface.ask(test_string1)
expected_user = getuser()
expected_result = ("I'm afraid I can't do that " + expected_user)
self.assertEqual(result, expected_result)
示例14: test_question_datetime_correct
def test_question_datetime_correct(self):
new_interface = Interface()
test_string1 = "What time is it?"
result = new_interface.ask(test_string1)
curr_time = datetime.now()
curr_time = curr_time.replace(second=0, microsecond=0)
self.assertEqual(result, str(curr_time))
示例15: test_ask_not_string
def test_ask_not_string(self):
"""
Test ask function not string
:return: assertion: exception: not string
"""
inquiry = Interface()
self.assertRaises(Exception, lambda: inquiry.ask(12))