Skip to content

Commit

Permalink
Fix metadata test fixture on Linux (#14)
Browse files Browse the repository at this point in the history
* Add user prefix to metadata test fixture on Linux and handle when the Linux filesystem doesn't support extended attributes
* Bump test coverage targets
  • Loading branch information
stefmolin authored Jun 8, 2024
1 parent 4912e6a commit 961e650
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ coverage:
status:
patch:
default:
target: 90%
target: 95%
project:
default: false
exif_stripper:
target: 90%
target: 95%
paths:
- "!tests/.*"
tests:
Expand Down
17 changes: 14 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import platform
import subprocess
from getpass import getuser

import pytest
from PIL import Image

from exif_stripper import cli

RUNNING_ON_WINDOWS = platform.system() == 'Windows'
RUNNING_ON = platform.system()
RUNNING_ON_WINDOWS = RUNNING_ON == 'Windows'

if not RUNNING_ON_WINDOWS:
from xattr import xattr
Expand All @@ -29,8 +31,17 @@ def image_with_exif_data(tmp_path):
@pytest.fixture
def image_with_metadata(image_with_exif_data):
"""Fixture for an image with metadata."""
if not RUNNING_ON_WINDOWS:
xattr(image_with_exif_data).set('the.limit.does.not.exist', b'\x00')
if RUNNING_ON in ['Darwin', 'Linux']:
try:
xattr(image_with_exif_data).set(
f'{getuser()}.test_extended_attribute'
if RUNNING_ON == 'Linux'
else 'com.apple.macl',
b'\x00',
)
except OSError: # pragma: nocover
# filesystem does not support extended attributes
pass
return image_with_exif_data


Expand Down

0 comments on commit 961e650

Please sign in to comment.