

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

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

import _pytest

from transformers.testing_utils import HfDoctestModule, HfDocTestParser


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
__A      		=     abspath(join(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 				snake_case_(_UpperCamelCase					)							->     Optional[Any]:



  """simple docstring"""






  config.addinivalue_line(
      '''markers'''			,	'''is_pt_tf_cross_test: mark test to run only when PT and TF interactions are tested'''					)
  config.addinivalue_line(
      '''markers'''			,	'''is_pt_flax_cross_test: mark test to run only when PT and FLAX interactions are tested'''					)
  config.addinivalue_line('''markers'''			,	'''is_pipeline_test: mark test to run only when pipelines are tested'''					)
  config.addinivalue_line('''markers'''			,	'''is_staging_test: mark test to run only in the staging environment'''					)
  config.addinivalue_line('''markers'''			,	'''accelerate_tests: mark test that require accelerate'''					)
  config.addinivalue_line('''markers'''			,	'''tool_tests: mark the tool tests that are run on their specific schedule'''					)



def 				snake_case_(_UpperCamelCase					)							->     Union[str, Any]:



  """simple docstring"""






  from transformers.testing_utils import pytest_addoption_shared

  pytest_addoption_shared(_UpperCamelCase					)



def 				snake_case_(_UpperCamelCase					)							->     List[str]:



  """simple docstring"""






  from transformers.testing_utils import pytest_terminal_summary_main

  _snake_case						=							terminalreporter.config.getoption('''--make-reports'''					)
  if make_reports:
    pytest_terminal_summary_main(_UpperCamelCase			,	id=_UpperCamelCase					)



def 				snake_case_(_UpperCamelCase			,	_UpperCamelCase					)							->     str:



  """simple docstring"""






  if exitstatus == 5:
    _snake_case						=							0


# Doctest custom flag to ignore output.
__A      		=     doctest.register_optionflag('''IGNORE_RESULT''')

__A      		=     doctest.OutputChecker



class   lowercase_   (  __lowercase					):



      def 						UpperCamelCase_		(      self				:    int      , A__				:    List[Any]      , A__				:    Optional[Any]      , A__				:    List[str]		)   ->					List[str]:
        if IGNORE_RESULT & optionflags:
          return True
        return OutputChecker.check_output(self      , A__      , A__      , A__		)

__A      		=     CustomOutputChecker
__A      		=     HfDoctestModule

__A      		=     HfDocTestParser




import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
 import ctypes
 import msvcrt  # noqa



 class   lowercase_   (  ctypes.Structure					):
       # _fields is a specific attr expected by ctypes
       UpperCamelCase_      :		List[Any]										=    [("size", ctypes.c_int), ("visible", ctypes.c_byte)]



def 				snake_case_()							->     int:



  """simple docstring"""






  if os.name == "nt":
    _snake_case						=							CursorInfo()
    _snake_case						=							ctypes.windll.kernelaa.GetStdHandle(-11					)
    ctypes.windll.kernelaa.GetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
    _snake_case						=							False
    ctypes.windll.kernelaa.SetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
  elif os.name == "posix":
    sys.stdout.write('''\033[?25l'''					)
    sys.stdout.flush()



def 				snake_case_()							->     Optional[Any]:



  """simple docstring"""






  if os.name == "nt":
    _snake_case						=							CursorInfo()
    _snake_case						=							ctypes.windll.kernelaa.GetStdHandle(-11					)
    ctypes.windll.kernelaa.GetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
    _snake_case						=							True
    ctypes.windll.kernelaa.SetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
  elif os.name == "posix":
    sys.stdout.write('''\033[?25h'''					)
    sys.stdout.flush()



@contextmanager
def 				snake_case_()							->     int:



  """simple docstring"""






  try:
    hide_cursor()
    yield
  finally:
    show_cursor()

