diff --git a/gradio/components.py b/gradio/components.py index 781ab58a3c..2316c50f33 100644 --- a/gradio/components.py +++ b/gradio/components.py @@ -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): diff --git a/test/test_data/__init__.py b/gradio/test_data/__init__.py similarity index 100% rename from test/test_data/__init__.py rename to gradio/test_data/__init__.py diff --git a/test/test_data/blocks_configs.py b/gradio/test_data/blocks_configs.py similarity index 100% rename from test/test_data/blocks_configs.py rename to gradio/test_data/blocks_configs.py diff --git a/test/test_data/cheetah1.jpg b/gradio/test_data/cheetah1.jpg similarity index 100% rename from test/test_data/cheetah1.jpg rename to gradio/test_data/cheetah1.jpg diff --git a/test/test_data/cheetah2.jpg b/gradio/test_data/cheetah2.jpg similarity index 100% rename from test/test_data/cheetah2.jpg rename to gradio/test_data/cheetah2.jpg diff --git a/test/test_data/flagged_no_log/a.txt b/gradio/test_data/flagged_no_log/a.txt similarity index 100% rename from test/test_data/flagged_no_log/a.txt rename to gradio/test_data/flagged_no_log/a.txt diff --git a/test/test_data/flagged_no_log/b.txt b/gradio/test_data/flagged_no_log/b.txt similarity index 100% rename from test/test_data/flagged_no_log/b.txt rename to gradio/test_data/flagged_no_log/b.txt diff --git a/test/test_data/flagged_no_log/c.txt b/gradio/test_data/flagged_no_log/c.txt similarity index 100% rename from test/test_data/flagged_no_log/c.txt rename to gradio/test_data/flagged_no_log/c.txt diff --git a/test/test_data/flagged_with_log/log.csv b/gradio/test_data/flagged_with_log/log.csv similarity index 100% rename from test/test_data/flagged_with_log/log.csv rename to gradio/test_data/flagged_with_log/log.csv diff --git a/test/test_data/lion.jpg b/gradio/test_data/lion.jpg similarity index 100% rename from test/test_data/lion.jpg rename to gradio/test_data/lion.jpg diff --git a/test/test_data/media_data.py b/gradio/test_data/media_data.py similarity index 100% rename from test/test_data/media_data.py rename to gradio/test_data/media_data.py diff --git a/test/test_data/test_audio.wav b/gradio/test_data/test_audio.wav similarity index 100% rename from test/test_data/test_audio.wav rename to gradio/test_data/test_audio.wav diff --git a/test/test_data/test_image.png b/gradio/test_data/test_image.png similarity index 100% rename from test/test_data/test_image.png rename to gradio/test_data/test_image.png diff --git a/test/test_blocks.py b/test/test_blocks.py index 99aeee34a2..fa8a908847 100644 --- a/test/test_blocks.py +++ b/test/test_blocks.py @@ -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): diff --git a/test/test_components.py b/test/test_components.py index 7e7324e53b..d9111effca 100644 --- a/test/test_components.py +++ b/test/test_components.py @@ -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" diff --git a/test/test_encryptor.py b/test/test_encryptor.py index 21c7e77a03..d3b06050a5 100644 --- a/test/test_encryptor.py +++ b/test/test_encryptor.py @@ -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" diff --git a/test/test_external.py b/test/test_external.py index 1f3b2ef987..8f2aff86fc 100644 --- a/test/test_external.py +++ b/test/test_external.py @@ -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) diff --git a/test/test_inputs.py b/test/test_inputs.py index 480504fb84..d569c3371e 100644 --- a/test/test_inputs.py +++ b/test/test_inputs.py @@ -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" diff --git a/test/test_interfaces.py b/test/test_interfaces.py index 2b9f58bee2..33e317ae8e 100644 --- a/test/test_interfaces.py +++ b/test/test_interfaces.py @@ -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"]] diff --git a/test/test_interpretation.py b/test/test_interpretation.py index cb76faf937..a5db374f91 100644 --- a/test/test_interpretation.py +++ b/test/test_interpretation.py @@ -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" diff --git a/test/test_mix.py b/test/test_mix.py index dd74eb54cd..2d0786f825 100644 --- a/test/test_mix.py +++ b/test/test_mix.py @@ -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) diff --git a/test/test_outputs.py b/test/test_outputs.py index 8e14386800..7b9e91eafb 100644 --- a/test/test_outputs.py +++ b/test/test_outputs.py @@ -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" diff --git a/test/test_processing_utils.py b/test/test_processing_utils.py index 82f716015b..4145809ab2 100644 --- a/test/test_processing_utils.py +++ b/test/test_processing_utils.py @@ -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")