




import unittest
from pathlib import Path

from transformers import is_vision_available, load_tool
from transformers.testing_utils import get_tests_dir

from .test_tools_common import ToolTesterMixin


if is_vision_available():
      from PIL import Image





class 						SCREAMING_SNAKE_CASE__		(unittest.TestCase						,				_a ):
     def 					A__			(	self  :		int	):



       """simple docstring"""
       lowerCAmelCase__								=			load_tool('''image-question-answering'''	)
       self.tool.setup()
       lowerCAmelCase__								=			load_tool('''image-question-answering'''					,	remote=__lowerCamelCase	)
     def 					A__			(	self  :		List[Any]	):



       """simple docstring"""
       lowerCAmelCase__								=			Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''	)	) / '''000000039769.png'''	)
       lowerCAmelCase__								=			self.tool(__lowerCamelCase					,	'''How many cats are sleeping on the couch?'''	)
       self.assertEqual(__lowerCamelCase					,	'''2'''	)
     def 					A__			(	self  :		Optional[int]	):



       """simple docstring"""
       lowerCAmelCase__								=			Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''	)	) / '''000000039769.png'''	)
       lowerCAmelCase__								=			self.remote_tool(__lowerCamelCase					,	'''How many cats are sleeping on the couch?'''	)
       self.assertEqual(__lowerCamelCase					,	'''2'''	)
     def 					A__			(	self  :		Any	):



       """simple docstring"""
       lowerCAmelCase__								=			Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''	)	) / '''000000039769.png'''	)
       lowerCAmelCase__								=			self.tool(image=__lowerCamelCase					,	question='''How many cats are sleeping on the couch?'''	)
       self.assertEqual(__lowerCamelCase					,	'''2'''	)



     def 					A__			(	self  :		int	):



       """simple docstring"""
       lowerCAmelCase__								=			Image.open(Path(get_tests_dir('''fixtures/tests_samples/COCO'''	)	) / '''000000039769.png'''	)
       lowerCAmelCase__								=			self.remote_tool(image=__lowerCamelCase					,	question='''How many cats are sleeping on the couch?'''	)
       self.assertEqual(__lowerCamelCase					,	'''2'''	)








import json

import requests

from .fetch_github_info import AUTHENTICATED_USER_ENDPOINT, fetch_github_info
def 		a_       (   __lowerCAmelCase							):





  class 						SCREAMING_SNAKE_CASE__		:
       def __init__(	self  :		List[str]					,	__lowerCamelCase  :		Any	):



         """simple docstring"""
         assert isinstance(__lowerCamelCase					,	(bytes, str)	)
         lowerCAmelCase__								=			content



       def 					A__			(	self  :		int	):



         """simple docstring"""
         return json.loads(self.content	)

  def mock_response(*__lowerCAmelCase      ,   **__lowerCAmelCase							):
    assert args[0] == AUTHENTICATED_USER_ENDPOINT
    assert "Authorization" in kwargs["headers"]
    assert kwargs["headers"]["Authorization"].startswith('''token '''							)
    assert "Accept" in kwargs["headers"]
    return FakeResponse(B'''{"login":"test","id":1}'''							)

  monkeypatch.setattr(__lowerCAmelCase      ,   '''get'''      ,   __lowerCAmelCase							)
  lowerCAmelCase__								=			fetch_github_info('''token'''							)
  assert result["login"] == "test"
  assert result["id"] == 1

