diff --git a/elodie/media/base.py b/elodie/media/base.py index 73b662a..7cf27c4 100644 --- a/elodie/media/base.py +++ b/elodie/media/base.py @@ -187,9 +187,10 @@ class Base(object): extension = os.path.splitext(_file)[1][1:].lower() - for i in classes: - if(extension in i.extensions): - return i(_file) + if len(extension) > 0: + for i in classes: + if(extension in i.extensions): + return i(_file) return None diff --git a/elodie/tests/files/withoutextension b/elodie/tests/files/withoutextension new file mode 100644 index 0000000..e69de29 diff --git a/elodie/tests/media/base_test.py b/elodie/tests/media/base_test.py index cbceb3c..955d76b 100644 --- a/elodie/tests/media/base_test.py +++ b/elodie/tests/media/base_test.py @@ -15,6 +15,11 @@ sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.realp import helper from elodie.media.base import Base +from elodie.media.media import Media +from elodie.media.audio import Audio +from elodie.media.text import Text +from elodie.media.photo import Photo +from elodie.media.video import Video os.environ['TZ'] = 'GMT' @@ -33,3 +38,9 @@ def test_set_album_from_folder_invalid_file(): assert status == False, status +def test_get_class_by_file_without_extension(): + base_file = helper.get_file('withoutextension') + + cls = Base.get_class_by_file(base_file, [Audio, Text, Photo, Video]) + + assert cls is None, cls