blocks-move-test-data (#927)
* blocks-move-test-data - move test_data under gradio * blocks-move-test-data - typo * blocks-move-test-data - fix tests
@ -10,7 +10,6 @@ import shutil
|
||||
import tempfile
|
||||
import warnings
|
||||
from copy import deepcopy
|
||||
from test.test_data import media_data
|
||||
from types import ModuleType
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple
|
||||
|
||||
@ -23,6 +22,7 @@ from markdown_it import MarkdownIt
|
||||
|
||||
from gradio import processing_utils
|
||||
from gradio.blocks import Block
|
||||
from gradio.test_data import media_data
|
||||
|
||||
|
||||
class Component(Block):
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
@ -1,8 +1,8 @@
|
||||
import random
|
||||
import unittest
|
||||
from test.test_data.blocks_configs import XRAY_CONFIG
|
||||
|
||||
import gradio as gr
|
||||
from gradio.test_data.blocks_configs import XRAY_CONFIG
|
||||
|
||||
|
||||
class TestBlocks(unittest.TestCase):
|
||||
|
@ -4,7 +4,6 @@ import tempfile
|
||||
import unittest
|
||||
from copy import deepcopy
|
||||
from difflib import SequenceMatcher
|
||||
from test.test_data import media_data
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
@ -12,6 +11,7 @@ import pandas as pd
|
||||
import PIL
|
||||
|
||||
import gradio as gr
|
||||
from gradio.test_data import media_data
|
||||
|
||||
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import os
|
||||
import unittest
|
||||
from test.test_data.media_data import BASE64_IMAGE
|
||||
|
||||
from gradio import encryptor, processing_utils
|
||||
from gradio.test_data.media_data import BASE64_IMAGE
|
||||
|
||||
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
||||
|
||||
|
@ -195,7 +195,7 @@ class TestLoadInterface(unittest.TestCase):
|
||||
)
|
||||
io = gr.Interface(**interface_info)
|
||||
io.api_mode = True
|
||||
output = io("test/test_data/lion.jpg")
|
||||
output = io("gradio/test_data/lion.jpg")
|
||||
self.assertGreater(output["lion"], 0.5)
|
||||
|
||||
def test_translation_model(self):
|
||||
@ -218,7 +218,7 @@ class TestLoadInterface(unittest.TestCase):
|
||||
)
|
||||
io = gr.Interface(**interface_info)
|
||||
io.api_mode = True
|
||||
output = io("test/test_data/test_audio.wav")
|
||||
output = io("gradio/test_data/test_audio.wav")
|
||||
self.assertIsNotNone(output)
|
||||
|
||||
def test_text_to_image_model(self):
|
||||
@ -238,7 +238,7 @@ class TestLoadInterface(unittest.TestCase):
|
||||
interface_info = gr.external.load_interface("spaces/abidlabs/image-identity")
|
||||
io = gr.Interface(**interface_info)
|
||||
io.api_mode = True
|
||||
output = io("test/test_data/lion.jpg")
|
||||
output = io("gradio/test_data/lion.jpg")
|
||||
assertIsFile(output)
|
||||
|
||||
|
||||
|
@ -4,13 +4,13 @@ import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from difflib import SequenceMatcher
|
||||
from test.test_data import media_data
|
||||
|
||||
import numpy as np
|
||||
import pandas
|
||||
import PIL
|
||||
|
||||
import gradio as gr
|
||||
from gradio.test_data import media_data
|
||||
|
||||
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
||||
|
||||
|
@ -45,7 +45,9 @@ class TestInterface(unittest.TestCase):
|
||||
Interface(lambda x: x, examples=1234)
|
||||
|
||||
def test_examples_valid_path(self):
|
||||
path = os.path.join(os.path.dirname(__file__), "test_data/flagged_with_log")
|
||||
path = os.path.join(
|
||||
os.path.dirname(__file__), "../gradio/test_data/flagged_with_log"
|
||||
)
|
||||
interface = Interface(lambda x: 3 * x, "number", "number", examples=path)
|
||||
dataset_check = any(
|
||||
[c["type"] == "dataset" for c in interface.get_config_file()["components"]]
|
||||
|
@ -1,13 +1,13 @@
|
||||
import os
|
||||
import unittest
|
||||
from copy import deepcopy
|
||||
from test.test_data import media_data
|
||||
|
||||
import numpy as np
|
||||
|
||||
import gradio.interpretation
|
||||
from gradio import Interface
|
||||
from gradio.processing_utils import decode_base64_to_image
|
||||
from gradio.test_data import media_data
|
||||
|
||||
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
||||
|
||||
|
@ -23,7 +23,7 @@ class TestSeries(unittest.TestCase):
|
||||
io1 = gr.Interface.load("spaces/abidlabs/image-identity")
|
||||
io2 = gr.Interface.load("spaces/abidlabs/image-classifier")
|
||||
series = mix.Series(io1, io2)
|
||||
output = series("test/test_data/lion.jpg")
|
||||
output = series("gradio/test_data/lion.jpg")
|
||||
self.assertGreater(output["lion"], 0.5)
|
||||
|
||||
|
||||
|
@ -2,13 +2,13 @@ import json
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from test.test_data import media_data
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
import gradio as gr
|
||||
from gradio.test_data import media_data
|
||||
|
||||
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
||||
|
||||
|
@ -2,13 +2,13 @@ import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from copy import deepcopy
|
||||
from test.test_data import media_data
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
import gradio as gr
|
||||
from gradio.test_data import media_data
|
||||
|
||||
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
||||
|
||||
@ -22,13 +22,13 @@ class ImagePreprocessing(unittest.TestCase):
|
||||
|
||||
def test_encode_url_or_file_to_base64(self):
|
||||
output_base64 = gr.processing_utils.encode_url_or_file_to_base64(
|
||||
"test/test_data/test_image.png"
|
||||
"gradio/test_data/test_image.png"
|
||||
)
|
||||
self.assertEquals(output_base64, deepcopy(media_data.BASE64_IMAGE))
|
||||
|
||||
def test_encode_file_to_base64(self):
|
||||
output_base64 = gr.processing_utils.encode_file_to_base64(
|
||||
"test/test_data/test_image.png"
|
||||
"gradio/test_data/test_image.png"
|
||||
)
|
||||
self.assertEquals(output_base64, deepcopy(media_data.BASE64_IMAGE))
|
||||
|
||||
@ -47,14 +47,14 @@ class ImagePreprocessing(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_encode_array_to_base64(self):
|
||||
img = Image.open("test/test_data/test_image.png")
|
||||
img = Image.open("gradio/test_data/test_image.png")
|
||||
img = img.convert("RGB")
|
||||
numpy_data = np.asarray(img, dtype=np.uint8)
|
||||
output_base64 = gr.processing_utils.encode_array_to_base64(numpy_data)
|
||||
self.assertEqual(output_base64, deepcopy(media_data.ARRAY_TO_BASE64_IMAGE))
|
||||
|
||||
def test_resize_and_crop(self):
|
||||
img = Image.open("test/test_data/test_image.png")
|
||||
img = Image.open("gradio/test_data/test_image.png")
|
||||
new_img = gr.processing_utils.resize_and_crop(img, (20, 20))
|
||||
self.assertEqual(new_img.size, (20, 20))
|
||||
self.assertRaises(
|
||||
@ -66,12 +66,12 @@ class ImagePreprocessing(unittest.TestCase):
|
||||
|
||||
class AudioPreprocessing(unittest.TestCase):
|
||||
def test_audio_from_file(self):
|
||||
audio = gr.processing_utils.audio_from_file("test/test_data/test_audio.wav")
|
||||
audio = gr.processing_utils.audio_from_file("gradio/test_data/test_audio.wav")
|
||||
self.assertEqual(audio[0], 22050)
|
||||
self.assertIsInstance(audio[1], np.ndarray)
|
||||
|
||||
def test_audio_to_file(self):
|
||||
audio = gr.processing_utils.audio_from_file("test/test_data/test_audio.wav")
|
||||
audio = gr.processing_utils.audio_from_file("gradio/test_data/test_audio.wav")
|
||||
gr.processing_utils.audio_to_file(audio[0], audio[1], "test_audio_to_file")
|
||||
self.assertTrue(os.path.exists("test_audio_to_file"))
|
||||
os.remove("test_audio_to_file")
|
||||
|