Replace log tests with gmt info instead of psxy
The tests were sometimes failing with segfaults for no apparent reason.
It's more reliable to use 'info' with a bogus input file than 'psxy'
with no input given.
@@ -84,16 +84,19 @@ def test_errors_sent_to_log_file():
mode = lib.get_constant('GMT_MODULE_CMD')
with lib.log_to_file() as logfile:
assert os.path.exists(logfile)
+ data_file = 'not-a-valid-data-file.bla'
# Make a bogus module call that will fail
status = lib._c_call_module(lib.current_session,
- 'psxy'.encode(),
+ 'info'.encode(),
mode,
- '-JM6i'.encode())
+ data_file.encode())
assert status != 0
# Check the file content
with open(logfile) as flog:
log = flog.read()
- assert log.strip() == 'gmtinfo [ERROR]: No input data found!'
+ msg = 'gmtinfo [ERROR]: Error for input file: No such file ({})'.format(
+ data_file)
+ assert log.strip() == msg
# Log should be deleted as soon as the with is over
assert not os.path.exists(logfile)
@@ -113,19 +116,20 @@ def test_call_module():
def test_call_module_error_message():
"Check that the exception has the error message from call_module"
- with LibGMT() as lib:
- # Make a bogus module call that will fail
- try:
- lib.call_module('psxy', '-JM3i')
- except GMTCLibError as error:
+ data_file = 'bogus-data.bla'
true_msg = '\n'.join([
- "'psxy' failed (error: 69).",
+ "'info' failed (error: 69).",
"---------- Error log ----------",
'',
- 'gmtinfo [ERROR]: No input data found!',
+ 'gmtinfo [ERROR]: Error for input file: No such file (bogus-data.bla)',
'',
"-------------------------------",
])
+ with LibGMT() as lib:
+ # Make a bogus module call that will fail
+ try:
+ lib.call_module('info', data_file)
+ except GMTCLibError as error:
assert str(error) == true_msg
else:
assert False, "Didn't raise an exception"
