FIX randomdir broken by files with unknown mimetype
This commit is contained in:
parent
9e5c0335fa
commit
c3d7015d9d
2 changed files with 16 additions and 0 deletions
|
@ -20,6 +20,8 @@ def multi_fnmatch(fname, extensions):
|
||||||
|
|
||||||
def is_audio(fname):
|
def is_audio(fname):
|
||||||
mimetype = mimetypes.guess_type(fname)[0]
|
mimetype = mimetypes.guess_type(fname)[0]
|
||||||
|
if mimetype is None:
|
||||||
|
return False
|
||||||
return mimetype.split('/')[0] == 'audio'
|
return mimetype.split('/')[0] == 'audio'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,3 +43,17 @@ def test_same_name(tmpdir):
|
||||||
p.write('')
|
p.write('')
|
||||||
|
|
||||||
assert len(candidates([P(tmpdir)])) == 2
|
assert len(candidates([P(tmpdir)])) == 2
|
||||||
|
|
||||||
|
|
||||||
|
def test_unknown_mime_ignore(tmpdir):
|
||||||
|
p = tmpdir.join("foo.???")
|
||||||
|
p.write('')
|
||||||
|
assert len(candidates([P(tmpdir)])) == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_unknown_mime_nocrash(tmpdir):
|
||||||
|
p = tmpdir.join("foo.???")
|
||||||
|
p.write('')
|
||||||
|
p = tmpdir.join("foo.ogg")
|
||||||
|
p.write('')
|
||||||
|
assert len(candidates([P(tmpdir)])) == 1
|
||||||
|
|
Loading…
Reference in a new issue