Skip to content

Refactor tests in test_image.py to avoid writes inside assets #3002

Closed
@datumbox

Description

@datumbox

Currently some of the tests in test_image.py write inside the assets folder. Example:

vision/test/test_image.py

Lines 113 to 125 in 78159d6

def test_write_jpeg(self):
for img_path in get_images(IMAGE_ROOT, ".jpg"):
data = read_file(img_path)
img = decode_jpeg(data)
basedir = os.path.dirname(img_path)
filename, _ = os.path.splitext(os.path.basename(img_path))
torch_jpeg = os.path.join(
basedir, '{0}_torch.jpg'.format(filename))
pil_jpeg = os.path.join(
basedir, 'jpeg_write', '{0}_pil.jpg'.format(filename))
write_jpeg(img, torch_jpeg, quality=75)

As per discussion here, all tests that write to files should write to temporary locations via tempfile or similar solutions. It's worth ensuring that the solution works seamlessly on Windows.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions