[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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user