Bug 64655 - Test failures with shared-mime-info-1.1
Summary: Test failures with shared-mime-info-1.1
Status: RESOLVED FIXED
Alias: None
Product: PyXDG
Classification: Unclassified
Component: PyXDG (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Thomas Kluyver
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-15 23:55 UTC by Arfrever Frehtes Taifersar Arahesis
Modified: 2018-02-02 14:53 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Arfrever Frehtes Taifersar Arahesis 2013-05-15 23:55:37 UTC
The following test failures occur with shared-mime-info-1.1 and do not occur with shared-mime-info-1.0.

$ nosetests-3.3
............................................FF.........
======================================================================
FAIL: test_get_type (test-mime.MimeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyxdg/test/test-mime.py", line 59, in test_get_type
    self.check_mimetype(imgpng, 'image', 'png')
  File "/tmp/pyxdg/test/test-mime.py", line 15, in check_mimetype
    self.assertEqual(mimetype.subtype, subtype)
AssertionError: 'x-apple-ios-png' != 'png'
- x-apple-ios-png
+ png


======================================================================
FAIL: test_get_type2 (test-mime.MimeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyxdg/test/test-mime.py", line 83, in test_get_type2
    self.check_mimetype(Mime.get_type2(example_file('test.png')), 'image', 'png')
  File "/tmp/pyxdg/test/test-mime.py", line 15, in check_mimetype
    self.assertEqual(mimetype.subtype, subtype)
AssertionError: 'x-apple-ios-png' != 'png'
- x-apple-ios-png
+ png


----------------------------------------------------------------------
Ran 55 tests in 2.064s

FAILED (failures=2)
Comment 1 Thomas Kluyver 2013-05-16 12:29:56 UTC
What version of PyXDG is this with? It looks similar to bug #61817, which is already fixed in master. See also this mailing list thread:

http://lists.freedesktop.org/archives/xdg/2013-March/012678.html
Comment 2 Arfrever Frehtes Taifersar Arahesis 2013-05-16 12:38:49 UTC
This bug is present in PyXDG 0.25 and git head.
(PyXDG 0.25 has only failure in test_get_type. test_get_type2 was added after 0.25 release.)
Comment 3 Thomas Kluyver 2013-05-16 13:10:51 UTC
Drat, it's an intermittent failure. Test runs randomly pass or fail. I'll have a look into it, thanks.
Comment 4 Thomas Kluyver 2013-05-16 14:06:08 UTC
Unfortunately, according to the spec, both results are equally valid given the data shipped in SMI 1.1. The real fix is this change to the shared-mime-info data:

http://cgit.freedesktop.org/xdg/shared-mime-info/commit/freedesktop.org.xml.in?id=0c41ac819d483b3de89de1c2e58cdfbcf1f0f3c7

But that didn't make it into 1.1. Ugh, I've got three bad options:

- Ignore it, but image/png is an important mime type that could cause lots of problems if it's not correctly recognised.
- Add a special case for png, but that's always horrible.
- Preserve the order of globs read the file, which is presumably what other implementations do, but it's not required by the spec and it makes the code less tidy, pretty much just for this one bug.

(Note to self - failure is repeatable by running PYTHONHASHSEED=2 nosetests-3.3)
Comment 5 Nikoli 2014-01-19 21:45:08 UTC
shared-mime-info-1.2 was released, but it seems like this bug is still not fixed.
Comment 6 Thomas Kluyver 2018-02-02 14:53:07 UTC
I later decided to avoid the problematic case in the tests:
https://cgit.freedesktop.org/xdg/pyxdg/commit/?id=8f2888721b05b6298eb44d667bece464b7de5c8a


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.