mypy: Improve test_dialogflow.py, to pass with strict-optional.
This commit is contained in:
		
							parent
							
								
									1928841256
								
							
						
					
					
						commit
						6489f78edd
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		| 
						 | 
					@ -27,8 +27,12 @@ class MockHttplibRequest():
 | 
				
			||||||
@contextmanager
 | 
					@contextmanager
 | 
				
			||||||
def mock_dialogflow(test_name: str, bot_name: str) -> Any:
 | 
					def mock_dialogflow(test_name: str, bot_name: str) -> Any:
 | 
				
			||||||
    response_data = read_bot_fixture_data(bot_name, test_name)
 | 
					    response_data = read_bot_fixture_data(bot_name, test_name)
 | 
				
			||||||
    df_request = response_data.get('request')
 | 
					    try:
 | 
				
			||||||
    df_response = response_data.get('response')
 | 
					        df_request = response_data['request']
 | 
				
			||||||
 | 
					        df_response = response_data['response']
 | 
				
			||||||
 | 
					    except KeyError:
 | 
				
			||||||
 | 
					        print("ERROR: 'request' or 'response' field not found in fixture.")
 | 
				
			||||||
 | 
					        raise
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    with patch('apiai.ApiAI.text_request') as mock_text_request:
 | 
					    with patch('apiai.ApiAI.text_request') as mock_text_request:
 | 
				
			||||||
        request = MockTextRequest()
 | 
					        request = MockTextRequest()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue