def test_flip_input_string(): ''' Test that if the input is string. ''' with pytest.raises(AttributeError): flip(123, test_output_file_path, "v")
def test_flip_output_string(): ''' Test that if the output is string. ''' with pytest.raises(ValueError): flip(test_input_file_path, 123, "v")
def test_invalid_input(): ''' Test if the input direction is valid ''' with pytest.raises(AssertionError): flip(test_input_file_path, test_output_file_path, "123")
def test_nonexistent_input_path(): ''' Test if the input path exists or not ''' with pytest.raises(FileNotFoundError): flip("test_imgs/hello/world.png", test_output_file_path, "v")
def test_nonexistent_output_path(): ''' Test if the output path exists or not ''' with pytest.raises(FileNotFoundError): flip(test_input_file_path, "./123/456.jpg", "v")
def test_flip_input_shape(): ''' Test that if the image has correct shape ''' flip(test_input_file_path, test_output_file_path, "v") input_img = skimage.io.imread(test_input_file_path) assert np.size(input_img.shape) == 3
def test_flip_same_size(): ''' Test that the output size is correct ''' flip(test_input_file_path, test_output_file_path, "v") input_img = skimage.io.imread(test_input_file_path) test_output = skimage.io.imread(test_output_file_path) assert input_img.shape == test_output.shape, "Input and output shape are not the same"
def test_flip_input_type(): ''' Test that if the input type is png. ''' with pytest.raises(OSError): flip("test_imgs/emboss/input.pdf", test_output_file_path, "v") with pytest.raises(OSError): flip("test_input.jpg", test_output_file_path, "v")
def test_flip_h(): flip(test_input_file_path, test_output_file_path, "h") test_output_h = skimage.io.imread(test_output_file_path) assert np.array_equal( test_output_h, exp_output_h), "The flip function does not work properly."