2022-08-23 04:04:59 +08:00
|
|
|
import inspect
|
2022-08-17 01:21:13 +08:00
|
|
|
import pathlib
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2022-08-23 04:04:59 +08:00
|
|
|
import gradio as gr
|
|
|
|
|
2022-08-17 01:21:13 +08:00
|
|
|
|
2022-07-12 01:20:11 +08:00
|
|
|
def pytest_configure(config):
|
|
|
|
config.addinivalue_line(
|
|
|
|
"markers", "flaky: mark test as flaky. Failure will not cause te"
|
|
|
|
)
|
2022-08-17 01:21:13 +08:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def test_file_dir():
|
|
|
|
return pathlib.Path(pathlib.Path(__file__).parent, "test_files")
|
2022-08-23 04:04:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def io_components():
|
|
|
|
classes_to_check = gr.components.IOComponent.__subclasses__()
|
|
|
|
subclasses = []
|
|
|
|
|
|
|
|
while classes_to_check:
|
|
|
|
subclass = classes_to_check.pop()
|
|
|
|
children = subclass.__subclasses__()
|
|
|
|
|
|
|
|
if children:
|
|
|
|
classes_to_check.extend(children)
|
|
|
|
if "value" in inspect.signature(subclass).parameters:
|
|
|
|
subclasses.append(subclass)
|
|
|
|
|
|
|
|
return subclasses
|