|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import doctest |
|
import sys |
|
import warnings |
|
from os.path import abspath, dirname, join |
|
|
|
|
|
|
|
|
|
git_repo_path = abspath(join(dirname(__file__), "src")) |
|
sys.path.insert(1, git_repo_path) |
|
|
|
|
|
|
|
warnings.simplefilter(action="ignore", category=FutureWarning) |
|
|
|
|
|
def pytest_configure(config): |
|
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") |
|
|
|
|
|
def pytest_addoption(parser): |
|
from transformers.testing_utils import pytest_addoption_shared |
|
|
|
pytest_addoption_shared(parser) |
|
|
|
|
|
def pytest_terminal_summary(terminalreporter): |
|
from transformers.testing_utils import pytest_terminal_summary_main |
|
|
|
make_reports = terminalreporter.config.getoption("--make-reports") |
|
if make_reports: |
|
pytest_terminal_summary_main(terminalreporter, id=make_reports) |
|
|
|
|
|
def pytest_sessionfinish(session, exitstatus): |
|
|
|
if exitstatus == 5: |
|
session.exitstatus = 0 |
|
|
|
|
|
|
|
IGNORE_RESULT = doctest.register_optionflag('IGNORE_RESULT') |
|
|
|
OutputChecker = doctest.OutputChecker |
|
|
|
|
|
class CustomOutputChecker(OutputChecker): |
|
def check_output(self, want, got, optionflags): |
|
if IGNORE_RESULT & optionflags: |
|
return True |
|
return OutputChecker.check_output(self, want, got, optionflags) |
|
|
|
|
|
doctest.OutputChecker = CustomOutputChecker |
|
|