2019-02-28 13:51:51 +08:00
|
|
|
import unittest
|
|
|
|
from gradio import Interface
|
|
|
|
import gradio.inputs
|
|
|
|
import gradio.outputs
|
|
|
|
|
|
|
|
|
|
|
|
class TestInterface(unittest.TestCase):
|
|
|
|
def test_input_output_mapping(self):
|
|
|
|
io = Interface(inputs='SketCHPad', outputs='textBOX', model=lambda x: x, model_type='function')
|
|
|
|
self.assertIsInstance(io.input_interface, gradio.inputs.Sketchpad)
|
|
|
|
self.assertIsInstance(io.output_interface, gradio.outputs.Textbox)
|
|
|
|
|
2019-03-06 14:45:08 +08:00
|
|
|
def test_input_interface_is_instance(self):
|
|
|
|
inp = gradio.inputs.ImageUpload()
|
|
|
|
io = Interface(inputs=inp, outputs='textBOX', model=lambda x: x, model_type='function')
|
|
|
|
self.assertEqual(io.input_interface, inp)
|
|
|
|
|
|
|
|
def test_output_interface_is_instance(self):
|
|
|
|
out = gradio.outputs.Label(show_confidences=False)
|
|
|
|
io = Interface(inputs='SketCHPad', outputs=out, model=lambda x: x, model_type='function')
|
|
|
|
self.assertEqual(io.input_interface, inp)
|
|
|
|
|
2019-02-28 13:51:51 +08:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|