mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-15 02:11:15 +08:00
unittests for mix
This commit is contained in:
parent
2e1cec2677
commit
ebef388ba9
25
test/test_mix.py
Normal file
25
test/test_mix.py
Normal file
@ -0,0 +1,25 @@
|
||||
import unittest
|
||||
import gradio as gr
|
||||
from gradio import mix
|
||||
|
||||
class TestSeries(unittest.TestCase):
|
||||
def test_in_interface(self):
|
||||
io1 = gr.Interface(lambda x: x + " World", "textbox",
|
||||
gr.outputs.Textbox())
|
||||
io2 = gr.Interface(lambda x: x + "!", "textbox", gr.outputs.Textbox())
|
||||
series = mix.Series(io1, io2)
|
||||
self.assertEqual(series.process(["Hello"])[0], ["Hello World!"])
|
||||
|
||||
class TestParallel(unittest.TestCase):
|
||||
def test_in_interface(self):
|
||||
io1 = gr.Interface(lambda x: x + " World 1!", "textbox",
|
||||
gr.outputs.Textbox())
|
||||
io2 = gr.Interface(lambda x: x + " World 2!", "textbox",
|
||||
gr.outputs.Textbox())
|
||||
parallel = mix.Parallel(io1, io2)
|
||||
self.assertEqual(parallel.process(["Hello"])[0], ["Hello World 1!",
|
||||
"Hello World 2!"])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -1,22 +0,0 @@
|
||||
import unittest
|
||||
import gradio as gr
|
||||
import PIL
|
||||
import numpy as np
|
||||
import scipy
|
||||
import os
|
||||
|
||||
|
||||
class TestParallel(unittest.TestCase):
|
||||
def test_in_interface(self):
|
||||
io1 = gr.Interface(lambda x: x + " world", "textbox",
|
||||
gr.outputs.Textbox())
|
||||
io2 = gr.Interface(lambda x: x + "!", "textbox", gr.outputs.Textbox())
|
||||
series = gr.transforms.Series(io1, io2)
|
||||
self.assertEqual(series.process(["Hello"])[0], ["Hello world!"])
|
||||
# io2 = gr.Interface(lambda x: x / 2, "number",
|
||||
# gr.outputs.Textbox(type="number"))
|
||||
# self.assertEqual(iface.process([10])[0], [5])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user