gh-93 Update media module to test for string before calling string functions
This commit is contained in:
parent
ed127aa402
commit
f234cb989d
|
@ -295,6 +295,9 @@ class Media(object):
|
|||
|
||||
@classmethod
|
||||
def get_class_by_file(cls, _file, classes):
|
||||
if not isinstance(_file, basestring) or not os.path.isfile(_file):
|
||||
return None
|
||||
|
||||
extension = os.path.splitext(_file)[1][1:].lower()
|
||||
|
||||
for i in classes:
|
||||
|
|
Binary file not shown.
|
@ -43,11 +43,24 @@ def test_get_class_by_file_unsupported():
|
|||
|
||||
assert media is None
|
||||
|
||||
def test_get_class_by_file_empty():
|
||||
def test_get_class_by_file_ds_store():
|
||||
media = Media.get_class_by_file(helper.get_file('.DS_Store'),
|
||||
[Photo, Video, Audio])
|
||||
assert media is None
|
||||
|
||||
def test_get_class_by_file_invalid_type():
|
||||
media = Media.get_class_by_file(None,
|
||||
[Photo, Video, Audio])
|
||||
assert media is None
|
||||
|
||||
media = Media.get_class_by_file(False,
|
||||
[Photo, Video, Audio])
|
||||
assert media is None
|
||||
|
||||
media = Media.get_class_by_file(True,
|
||||
[Photo, Video, Audio])
|
||||
assert media is None
|
||||
|
||||
def is_valid():
|
||||
media = Media()
|
||||
|
||||
|
|
Loading…
Reference in New Issue