From 680b0f3fe90a01052ca36865d003c1c6141b1733 Mon Sep 17 00:00:00 2001 From: Mohan Kumar Date: Fri, 9 Jul 2021 13:29:29 +0530 Subject: [PATCH 1/2] test for invalid url --- tests/test_errors.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index 595c54b..e6878b7 100755 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -7,7 +7,6 @@ import pytest import camelot - testdir = os.path.dirname(os.path.abspath(__file__)) testdir = os.path.join(testdir, "files") filename = os.path.join(testdir, "foo.pdf") @@ -118,3 +117,9 @@ def test_bad_password(): message = "file has not been decrypted" with pytest.raises(Exception, match=message): tables = camelot.read_pdf(filename, password="wrongpass") + +def test_invalid_url(): + url = 'fttp://google.com/pdf' + message = "File format not supported" + with pytest.raises(Exception, match=message): + url = camelot.read_pdf(url) \ No newline at end of file From 647e4d26a8b554ba978d08bb9ecf30ab94332965 Mon Sep 17 00:00:00 2001 From: Mohan Kumar Date: Fri, 9 Jul 2021 20:14:53 +0530 Subject: [PATCH 2/2] coverage for is_url --- tests/test_errors.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_errors.py b/tests/test_errors.py index e6878b7..b94d800 100755 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -2,6 +2,7 @@ import os import warnings +from camelot.utils import is_url import pytest @@ -120,6 +121,4 @@ def test_bad_password(): def test_invalid_url(): url = 'fttp://google.com/pdf' - message = "File format not supported" - with pytest.raises(Exception, match=message): - url = camelot.read_pdf(url) \ No newline at end of file + assert is_url(url) == False \ No newline at end of file