





# 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.
_lowerCamelCase :    List[str]  							= 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 _a (  SCREAMING_SNAKE_CASE__      :  List[str]       )	->    Union[str, 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 _a (  SCREAMING_SNAKE_CASE__      :  Optional[int]       )	->    Optional[Any]:

							'''simple docstring'''






							from transformers.testing_utils import pytest_addoption_shared

							pytest_addoption_shared(SCREAMING_SNAKE_CASE__       )




def _a (  SCREAMING_SNAKE_CASE__      :  Optional[Any]       )	->    Optional[Any]:

							'''simple docstring'''






							from transformers.testing_utils import pytest_terminal_summary_main

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




def _a (  SCREAMING_SNAKE_CASE__      :  Any			,				SCREAMING_SNAKE_CASE__      :  Optional[int]       )	->    int:

							'''simple docstring'''






							if exitstatus == 5:
														SCREAMING_SNAKE_CASE__       :      List[Any]     =						0


# Doctest custom flag to ignore output.
_lowerCamelCase :    Any  							= doctest.register_optionflag('''IGNORE_RESULT''')

_lowerCamelCase :    Any  							= doctest.OutputChecker


class 						lowerCamelCase       (__lowerCamelCase      ):







							"""simple docstring"""




							def  A_     ( self     :					Optional[Any],			_UpperCAmelCase     :					Any,			_UpperCAmelCase     :					Optional[Any],			_UpperCAmelCase     :					Optional[int]						)				->			Any:





														"""simple docstring"""
														if IGNORE_RESULT & optionflags:
																					return True
														return OutputChecker.check_output(self,			_UpperCAmelCase,			_UpperCAmelCase,			_UpperCAmelCase						)


_lowerCamelCase :    Dict  							= CustomOutputChecker
_lowerCamelCase :    List[Any]  							= HfDoctestModule







_lowerCamelCase :    Dict  							= HfDocTestParser













import pytest

from datasets.splits import SplitDict, SplitInfo
from datasets.utils.py_utils import asdict




@pytest.mark.parametrize(
    "split_dict"			,				[
        SplitDict(),
        SplitDict({"train": SplitInfo(name="train"			,				num_bytes=13_37			,				num_examples=42			,				dataset_name="my_dataset"       )}       ),
        SplitDict({"train": SplitInfo(name="train"			,				num_bytes=13_37			,				num_examples=42       )}       ),
        SplitDict({"train": SplitInfo()}       ),
    ]			,				)
def _a (  SCREAMING_SNAKE_CASE__      :  SplitDict       )	->    str:

							'''simple docstring'''






							SCREAMING_SNAKE_CASE__       :      Dict     =						split_dict._to_yaml_list()
							assert len(SCREAMING_SNAKE_CASE__       ) == len(SCREAMING_SNAKE_CASE__       )
							SCREAMING_SNAKE_CASE__       :      List[Any]     =						SplitDict._from_yaml_list(SCREAMING_SNAKE_CASE__       )
							for split_name, split_info in split_dict.items():
														# dataset_name field is deprecated, and is therefore not part of the YAML dump
														SCREAMING_SNAKE_CASE__       :      str     =						None
														# the split name of split_dict takes over the name of the split info object
														SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						split_name
							assert split_dict == reloaded







@pytest.mark.parametrize(
    "split_info"			,				[SplitInfo(), SplitInfo(dataset_name=SCREAMING_SNAKE_CASE__       ), SplitInfo(dataset_name="my_dataset"       )]       )
def _a (  SCREAMING_SNAKE_CASE__      :  Any       )	->    Dict:

							'''simple docstring'''






							SCREAMING_SNAKE_CASE__       :      str     =						asdict(SplitDict({"train": split_info}       )       )
							assert "dataset_name" in split_dict_asdict["train"]
							assert split_dict_asdict["train"]["dataset_name"] == split_info.dataset_name






