Spaces:
Running
Running
File size: 947 Bytes
3e506b8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import unittest
from PIL import Image
from inference import generate_image
class TestGenerateImage(unittest.TestCase):
def test_generate_image_output_type(self):
img = generate_image(image_idx=0, x=0.5, y=0.5)
self.assertIsInstance(img, Image.Image)
def test_generate_image_valid_coordinates(self):
img = generate_image(image_idx=0, x=0.1, y=0.9)
self.assertIsInstance(img, Image.Image)
def test_generate_image_edge_coordinates(self):
img = generate_image(image_idx=1, x=0.0, y=1.0)
self.assertIsInstance(img, Image.Image)
def test_generate_image_invalid_image_idx(self):
with self.assertRaises(KeyError):
generate_image(image_idx=2, x=0.5, y=0.5)
def test_generate_image_eps_boundary(self):
img = generate_image(image_idx=0, x=1e-5, y=1 - 1e-5)
self.assertIsInstance(img, Image.Image)
if __name__ == "__main__":
unittest.main()
|