Skip to content

Commit 128508c

Browse files
committed
fix: Ignore deprecation warnings in test logs
1 parent 5dbc6a7 commit 128508c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/c2pa/c2pa.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,15 @@ def read_file(path: Union[str, Path],
534534
data_dir: Union[str, Path]) -> str:
535535
"""Read a C2PA manifest from a file.
536536
537+
.. deprecated:: 0.10.12
538+
This function is deprecated and will be removed in a future version.
539+
Please use the Reader class for reading C2PA metadata instead.
540+
Example:
541+
```python
542+
with Reader(path) as reader:
543+
manifest_json = reader.json()
544+
```
545+
537546
Args:
538547
path: Path to the file to read
539548
data_dir: Directory to write binary resources to
@@ -544,6 +553,13 @@ def read_file(path: Union[str, Path],
544553
Raises:
545554
C2paError: If there was an error reading the file
546555
"""
556+
warnings.warn(
557+
"The read_file function is deprecated and will be removed in a future version. "
558+
"Please use the Reader class for reading C2PA metadata instead.",
559+
DeprecationWarning,
560+
stacklevel=2
561+
)
562+
547563
container = _StringContainer()
548564

549565
container._path_str = str(path).encode('utf-8')

tests/test_unit_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
import unittest
1818
from unittest.mock import mock_open, patch
1919
import ctypes
20+
import warnings
2021

2122
from c2pa import Builder, C2paError as Error, Reader, C2paSigningAlg as SigningAlg, C2paSignerInfo, Signer, sdk_version
2223
from c2pa.c2pa import Stream, read_ingredient_file, read_file, sign_file
2324

25+
# Suppress deprecation warnings
26+
warnings.filterwarnings("ignore", category=DeprecationWarning)
27+
2428
PROJECT_PATH = os.getcwd()
2529

2630
testPath = os.path.join(PROJECT_PATH, "tests", "fixtures", "C.jpg")

0 commit comments

Comments
 (0)