From 859610e0dc2a6a48bc1daf1a8ddbef6c19313f2b Mon Sep 17 00:00:00 2001 From: Vinayak Mehta Date: Wed, 2 Jan 2019 16:35:49 +0530 Subject: [PATCH] Add pages test --- camelot/handlers.py | 4 ++-- camelot/io.py | 3 ++- tests/test_common.py | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/camelot/handlers.py b/camelot/handlers.py index e0dd8c7..8f0cbcb 100644 --- a/camelot/handlers.py +++ b/camelot/handlers.py @@ -22,7 +22,7 @@ class PDFHandler(object): Filepath or URL of the PDF file. pages : str, optional (default: '1') Comma-separated page numbers. - Example: '1,3,4' or '1,4-end'. + Example: '1,3,4' or '1,4-end' or 'all'. password : str, optional (default: None) Password for decryption. @@ -50,7 +50,7 @@ class PDFHandler(object): Filepath or URL of the PDF file. pages : str, optional (default: '1') Comma-separated page numbers. - Example: 1,3,4 or 1,4-end. + Example: '1,3,4' or '1,4-end' or 'all'. Returns ------- diff --git a/camelot/io.py b/camelot/io.py index bff5974..44f3354 100644 --- a/camelot/io.py +++ b/camelot/io.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + import warnings from .handlers import PDFHandler @@ -18,7 +19,7 @@ def read_pdf(filepath, pages='1', password=None, flavor='lattice', Filepath or URL of the PDF file. pages : str, optional (default: '1') Comma-separated page numbers. - Example: '1,3,4' or '1,4-end'. + Example: '1,3,4' or '1,4-end' or 'all'. password : str, optional (default: None) Password for decryption. flavor : str (default: 'lattice') diff --git a/tests/test_common.py b/tests/test_common.py index 0d95a02..f9f26bf 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -207,6 +207,24 @@ def test_repr(): assert repr(tables[0].cells[0][0]) == "" +def test_pages(): + url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf" + tables = camelot.read_pdf(url) + assert repr(tables) == "" + assert repr(tables[0]) == "" + assert repr(tables[0].cells[0][0]) == "" + + tables = camelot.read_pdf(url, pages='1-end') + assert repr(tables) == "" + assert repr(tables[0]) == "
" + assert repr(tables[0].cells[0][0]) == "" + + tables = camelot.read_pdf(url, pages='all') + assert repr(tables) == "" + assert repr(tables[0]) == "
" + assert repr(tables[0].cells[0][0]) == "" + + def test_url(): url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf" tables = camelot.read_pdf(url)