jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1243143?usp=email )
Change subject: Tests: Run complete djvu_tests.py on github
......................................................................
Tests: Run complete djvu_tests.py on github
- install DjVuLibre library on github
- remove coverage exclusions for TestDjVuFile#
- recover test_get_not_existing_page test
Bug: T317528
Change-Id: I4ea5c30b84aa1a3e453a2b20fe89a4d49d262ab3
---
M .github/workflows/pywikibot-ci.yml
M tests/djvu_tests.py
2 files changed, 27 insertions(+), 17 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.github/workflows/pywikibot-ci.yml
b/.github/workflows/pywikibot-ci.yml
index d739dac..767ce62 100644
--- a/.github/workflows/pywikibot-ci.yml
+++ b/.github/workflows/pywikibot-ci.yml
@@ -81,6 +81,12 @@
if [ -f dev-requirements.txt ]; then pip install -r
dev-requirements.txt; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install wikitextparser
+ - name: Install DjVuLibre
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y djvulibre-bin
+ command -v djvutxt
+ command -v ddjvu
- name: Install setuptools
if: ${{ (matrix.python-version >= '3.12') || (matrix.os ==
'macOS-latest') }}
run: pip install setuptools
diff --git a/tests/djvu_tests.py b/tests/djvu_tests.py
index 2998692..038eb87 100755
--- a/tests/djvu_tests.py
+++ b/tests/djvu_tests.py
@@ -31,6 +31,7 @@
file_djvu_wo_text = join_djvu_data_path('myfile_wo_text.djvu')
test_txt = 'A file with non-ASCII characters, \nlike é or ç'
+ err_msg = 'Page 100 not in file'
@classmethod
def setUpClass(cls) -> None:
@@ -42,59 +43,62 @@
stderr=subprocess.PIPE)
dp.communicate()
- def setUp(self) -> None: # pragma: no cover
+ def setUp(self) -> None:
"""Set up test."""
super().setUp()
self.djvu = DjVuFile(file_djvu)
- def test_number_of_images(self) -> None: # pragma: no cover
+ def test_number_of_images(self) -> None:
"""Test page number generator."""
self.assertEqual(self.djvu.number_of_images(), 4)
- def test_page_info(self) -> None: # pragma: no cover
+ def test_page_info(self) -> None:
"""Test page info retrieval."""
self.assertEqual(self.djvu.page_info(1),
('{myfile.djvu}', ('1092x221', 600)))
- def test_get_most_common_info(self) -> None: # pragma: no cover
+ def test_get_most_common_info(self) -> None:
"""Test that most common (size, dpi) are returned."""
self.assertEqual(self.djvu.get_most_common_info(), ('1092x221', 600))
- def test_has_text(self) -> None: # pragma: no cover
+ def test_has_text(self) -> None:
"""Test if djvu file contains text."""
self.assertTrue(self.djvu.has_text())
djvu = DjVuFile(self.file_djvu_wo_text)
self.assertFalse(djvu.has_text())
- def test_get_existing_page_number(self) -> None: # pragma: no cover
+ def test_get_existing_page_number(self) -> None:
"""Test text is returned for existing page number."""
self.assertTrue(self.djvu.has_text())
txt = self.djvu.get_page(1)
self.assertEqual(txt, self.test_txt)
- def test_get_not_existing_page_number(self) -> None: # pragma: no cover
+ def test_get_not_existing_page_number(self) -> None:
"""Test error is raised if djvu page number is out of range."""
self.assertTrue(self.djvu.has_text())
- with self.assertRaisesRegex(ValueError, 'Page 100 not in file'):
+ with self.assertRaisesRegex(ValueError, self.err_msg):
self.djvu.get_page(100)
- def test_get_not_existing_page(self) -> None: # pragma: no cover
+ def test_get_not_existing_page(self) -> None:
"""Test error is raised if djvu file has no text."""
- self.assertTrue(self.djvu.has_text())
- with self.assertRaisesRegex(ValueError, 'Page 0 not in file'):
- self.djvu.get_page(0)
+ djvu = DjVuFile(self.file_djvu_wo_text)
+ self.assertFalse(djvu.has_text())
+ with self.assertRaisesRegex(
+ ValueError,
+ f'Djvu file {self.file_djvu_wo_text} has no text layer'):
+ djvu.get_page(1)
- def test_whiten_not_existing_page_number(self) -> None: # pragma: no cover
+ def test_whiten_not_existing_page_number(self) -> None:
"""Test djvu page cannot be whitend if page number is out of range."""
- with self.assertRaisesRegex(ValueError, 'Page 100 not in file'):
+ with self.assertRaisesRegex(ValueError, self.err_msg):
self.djvu.whiten_page(100)
- def test_delete_not_existing_page_number(self) -> None: # pragma: no cover
+ def test_delete_not_existing_page_number(self) -> None:
"""Test djvu page cannot be deleted if page number is out of range."""
- with self.assertRaisesRegex(ValueError, 'Page 100 not in file'):
+ with self.assertRaisesRegex(ValueError, self.err_msg):
self.djvu.delete_page(100)
- def test_clear_cache(self) -> None: # pragma: no cover
+ def test_clear_cache(self) -> None:
"""Test if djvu file contains text."""
self.assertTrue(self.djvu.has_text())
self.djvu._has_text = False
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1243143?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4ea5c30b84aa1a3e453a2b20fe89a4d49d262ab3
Gerrit-Change-Number: 1243143
Gerrit-PatchSet: 7
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]