





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      UpperCamelCase_				(   unittest.TestCase ,     UpperCamelCase__			):


							def    _snake_case     (							self			:List[Any]						)      ->      List[Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					load_tool("""image-question-answering"""						)
									self.tool.setup()
									SCREAMING_SNAKE_CASE__								=					load_tool("""image-question-answering"""							, remote=__A						)


							def    _snake_case     (							self			:List[Any]						)      ->      List[str]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""						)						) / """000000039769.png"""						)
									SCREAMING_SNAKE_CASE__								=					self.tool(__A							, """How many cats are sleeping on the couch?"""						)
									self.assertEqual(__A							, """2"""						)


							def    _snake_case     (							self			:Union[str, Any]						)      ->      Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					Image.open(Path(get_tests_dir("""fixtures/tests_samples/COCO"""						)						) / """000000039769.png"""						)
									SCREAMING_SNAKE_CASE__								=					self.remote_tool(__A							, """How many cats are sleeping on the couch?"""						)
									self.assertEqual(__A							, """2"""						)


							def    _snake_case     (							self			:Tuple						)      ->      int:



									"""simple docstring"""



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


							def    _snake_case     (							self			:int						)      ->      Tuple:



									"""simple docstring"""



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






# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
_lowerCamelCase       =	abspath(join(dirname(dirname(dirname(__file__))), 'src'))
sys.path.insert(1, git_repo_path)


# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='ignore', category=FutureWarning)






def  SCREAMING_SNAKE_CASE__							(				UpperCamelCase__:							Tuple			):
		from transformers.testing_utils import pytest_addoption_shared

		pytest_addoption_shared(UpperCamelCase__			)






def  SCREAMING_SNAKE_CASE__							(				UpperCamelCase__:							Tuple			):
		from transformers.testing_utils import pytest_terminal_summary_main

		SCREAMING_SNAKE_CASE__								=					terminalreporter.config.getoption("""--make-reports"""			)
		if make_reports:
				pytest_terminal_summary_main(UpperCamelCase__    ,      id=UpperCamelCase__			)