[MRG] Use find_executable for gs and raise error if not found (#166)

* Use find_executable for gs and raise error if not found

* Remove unused variable

* Add test

* Use pytest monkeypatch
This commit is contained in:
Vinayak Mehta
2018-10-23 21:12:43 +05:30
committed by GitHub
parent f734af3a0b
commit a78ef7f841
2 changed files with 49 additions and 16 deletions
+15
View File
@@ -60,3 +60,18 @@ def test_no_tables_found_warnings_suppressed():
except Warning as e:
warning_text = str(e)
pytest.fail('Unexpected warning: {}'.format(warning_text))
def test_ghostscript_not_found(monkeypatch):
import distutils
def _find_executable_patch(arg):
return ''
monkeypatch.setattr(distutils.spawn, 'find_executable', _find_executable_patch)
message = ('Please make sure that Ghostscript is installed and available'
' on the PATH environment variable')
filename = os.path.join(testdir, 'foo.pdf')
with pytest.raises(Exception, message=message):
tables = camelot.read_pdf(filename)