Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
datumbox opened this issue Nov 13, 2020 · 0 comments · Fixed by #3018
Closed

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

datumbox opened this issue Nov 13, 2020 · 0 comments · Fixed by #3018

Comments

@datumbox
Copy link
Contributor

datumbox commented Nov 13, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants