diff --git a/comicapi/comicarchive.py b/comicapi/comicarchive.py index ebd335c..26fedae 100644 --- a/comicapi/comicarchive.py +++ b/comicapi/comicarchive.py @@ -30,8 +30,9 @@ import py7zr try: from unrar.cffi import rarfile + rar_support = True except: - pass + rar_support = True try: from PIL import Image @@ -879,7 +880,7 @@ class ComicArchive: self.page_list = [] for name in files: if ( - os.path.splitext(name)[1].lower() in [".jpg", "jpeg", ".png", ".gif", ".webp"] + os.path.splitext(name)[1].lower() in [".jpg", ".jpeg", ".png", ".gif", ".webp"] and os.path.basename(name)[0] != "." ): self.page_list.append(name) diff --git a/requirements_dev.txt b/requirements_dev.txt index 5f025ae..3fdc987 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -6,3 +6,4 @@ black>=22 flake8==4.* flake8-encodings isort>=5.10 +pytest==7.* \ No newline at end of file diff --git a/tests/data/fake_cbr.cbr b/tests/data/fake_cbr.cbr new file mode 100644 index 0000000..1157aec Binary files /dev/null and b/tests/data/fake_cbr.cbr differ diff --git a/tests/test_comicarchive.py b/tests/test_comicarchive.py new file mode 100644 index 0000000..853bd8b --- /dev/null +++ b/tests/test_comicarchive.py @@ -0,0 +1,21 @@ +from os.path import abspath, dirname, join + +from comicapi.comicarchive import ComicArchive, rar_support +import pytest + +thisdir = dirname(abspath(__file__)) + +@pytest.mark.xfail("rar_support") +def test_getPageNameList(): + ComicArchive.logo_data = b"" + c = ComicArchive(join(thisdir, "data", "fake_cbr.cbr")) + pageNameList = c.get_page_name_list() + + assert pageNameList == [ + "page0.jpg", + "Page1.jpeg", + "Page2.png", + "Page3.gif", + "page4.webp", + "page10.jpg", + ]