<reponame>gottadiveintopython/kivyx.uix.behavior.fontsizeadjustment<gh_stars>1-10
import pytest


@pytest.fixture(scope='session')
def text_provider():
    from kivy.core.text import Label as CoreLabel
    return {
        'LabelSDL2': 'sdl2', 'LabelPIL': 'pil', 'LabelPango': 'pango',
    }[CoreLabel.__name__]


@pytest.fixture(scope='session')
def all_fonts():
    from pathlib import Path
    from kivy.core.text import LabelBase
    return tuple(
        item
        for dir_ in LabelBase.get_system_fonts_dir()
        for item in Path(dir_).iterdir()
        if item.is_file() and item.suffix in ('.ttc', '.ttf', '.otf', )
    )


# BOOLEAN_PROPS_SDL2 = {
#     'font_blended', 'font_hinting', 'font_kerning', 'strikethrough',
#     'underline',
# }
# BOOLEAN_PROPS = {
#     'bold', 'markup', 'strip', 'italic', 'shorten', 'mipmap',
#     *BOOLEAN_PROPS_SDL2
# }

# def pytest_generate_tests(metafunc):
#     boolean_props = BOOLEAN_PROPS.intersection(metafunc.fixturenames)
#     for prop in boolean_props:
#         metafunc.parametrize(
#             prop, [False, True, ], ids=lambda value: prop if value else '')
#     if 'font_name' in metafunc.fixturenames:
#         metafunc.parametrize(
#             'font_name',
#             [DEFAULT_FONT, *metafunc.config.getoption('fontname')])


# def pytest_addoption(parser):
#     parser.addoption(
#         '--fontname',
#         action='append',
#         default=[],
#         help='add a font to be used for tests',
#     )
import pytest


@pytest.fixture(scope='session')
def text_provider():
    from kivy.core.text import Label as CoreLabel
    return {
        'LabelSDL2': 'sdl2', 'LabelPIL': 'pil', 'LabelPango': 'pango',
    }[CoreLabel.__name__]


@pytest.fixture(scope='session')
def all_fonts():
    from pathlib import Path
    from kivy.core.text import LabelBase
    return tuple(
        item
        for dir_ in LabelBase.get_system_fonts_dir()
        for item in Path(dir_).iterdir()
        if item.is_file() and item.suffix in ('.ttc', '.ttf', '.otf', )
    )


# BOOLEAN_PROPS_SDL2 = {
#     'font_blended', 'font_hinting', 'font_kerning', 'strikethrough',
#     'underline',
# }
# BOOLEAN_PROPS = {
#     'bold', 'markup', 'strip', 'italic', 'shorten', 'mipmap',
#     *BOOLEAN_PROPS_SDL2
# }

# def pytest_generate_tests(metafunc):
#     boolean_props = BOOLEAN_PROPS.intersection(metafunc.fixturenames)
#     for prop in boolean_props:
#         metafunc.parametrize(
#             prop, [False, True, ], ids=lambda value: prop if value else '')
#     if 'font_name' in metafunc.fixturenames:
#         metafunc.parametrize(
#             'font_name',
#             [DEFAULT_FONT, *metafunc.config.getoption('fontname')])


# def pytest_addoption(parser):
#     parser.addoption(
#         '--fontname',
#         action='append',
#         default=[],
#         help='add a font to be used for tests',
#     )
# BOOLEAN_PROPS_SDL2 = { #     'font_blended', 'font_hinting', 'font_kerning', 'strikethrough', #     'underline', # } # BOOLEAN_PROPS = { #     'bold', 'markup', 'strip', 'italic', 'shorten', 'mipmap', #     *BOOLEAN_PROPS_SDL2 # } # def pytest_generate_tests(metafunc): #     boolean_props = BOOLEAN_PROPS.intersection(metafunc.fixturenames) #     for prop in boolean_props: #         metafunc.parametrize( #             prop, [False, True, ], ids=lambda value: prop if value else '') #     if 'font_name' in metafunc.fixturenames: #         metafunc.parametrize( #             'font_name', #             [DEFAULT_FONT, *metafunc.config.getoption('fontname')]) # def pytest_addoption(parser): #     parser.addoption( #         '--fontname', #         action='append', #         default=[], #         help='add a font to be used for tests', #     )