Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9697368
D4619.id16370.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D4619.id16370.diff
View Options
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
Details
Attached
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
Attached To
D4619: test: Deal with divergent test output depending on magic version
Event Timeline
Log In to Comment