Page MenuHomeSoftware Heritage

D4619.id16370.diff
No OneTemporary

D4619.id16370.diff

diff --git a/swh/indexer/tests/test_mimetype.py b/swh/indexer/tests/test_mimetype.py
--- a/swh/indexer/tests/test_mimetype.py
+++ b/swh/indexer/tests/test_mimetype.py
@@ -29,14 +29,26 @@
"raw_text,mimetype,encoding",
[
("du français".encode(), "text/plain", "utf-8"),
- (b"def __init__(self):", "text/x-python", "us-ascii"),
+ (b"def __init__(self):", ("text/x-python", "text/x-script.python"), "us-ascii"),
(b"\xff\xfe\x00\x00\x00\x00\xff\xfe\xff\xff", "application/octet-stream", ""),
],
)
def test_compute_mimetype_encoding(raw_text, mimetype, encoding):
"""Compute mimetype encoding should return results"""
actual_result = compute_mimetype_encoding(raw_text)
- assert actual_result == {"mimetype": mimetype, "encoding": encoding}
+ if isinstance(mimetype, tuple):
+ # New magic version can return different results, this deals with such a case
+ expected_result = {"mimetype": mimetype[0], "encoding": encoding}
+ # as a fallback
+ fallback_expected_result = {"mimetype": mimetype[1], "encoding": encoding}
+ else:
+ expected_result = {"mimetype": mimetype, "encoding": encoding}
+ fallback_expected_result = expected_result
+
+ try:
+ assert actual_result == expected_result
+ except AssertionError:
+ assert actual_result == fallback_expected_result
CONFIG = {

File Metadata

Mime Type
text/plain
Expires
Sun, Aug 17, 11:32 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3224797

Event Timeline