helpers: improve test coverage of Resolution

This commit is contained in:
James R. Barlow
2021-04-07 23:26:37 -07:00
parent 8423bd549b
commit 9db9a3d6ec
2 changed files with 15 additions and 2 deletions
+4 -2
View File
@@ -54,7 +54,7 @@ class Resolution(namedtuple('Resolution', ('x', 'y'))):
def __str__(self):
return f"{self.x:f}x{self.y:f}"
def __repr__(self):
def __repr__(self): # pragma: no cover
return f"Resolution({self.x}x{self.y} dpi)"
@@ -200,7 +200,9 @@ def check_pdf(input_file: Path) -> bool:
pdf.check_linearization(sio)
except RuntimeError:
pass
except ( # Workaround for a problematic pikepdf version
except (
# Workaround for a problematic pikepdf version
# pragma: no cover
getattr(pikepdf, 'ForeignObjectError')
if pikepdf.__version__ == '2.1.0'
else NeverRaise
+11
View File
@@ -117,3 +117,14 @@ def test_shim_paths(tmp_path):
assert results[-3].endswith('tesseract-ocr'), results
assert results[-2].endswith(os.path.join('gs', '9.52', 'bin')), results
assert results[-1].endswith(os.path.join('gs', '9.51', 'bin')), results
def test_resolution():
Resolution = helpers.Resolution
dpi_100 = Resolution(100, 100)
dpi_200 = Resolution(200, 200)
assert dpi_100.is_square
assert not Resolution(100, 200).is_square
assert dpi_100 == Resolution(100, 100)
assert str(dpi_100) != str(dpi_200)
assert dpi_100.take_max([200, 300], [400]) == Resolution(300, 400)