mirror of
https://github.com/echemdata/galvani.git
synced 2025-12-14 01:15:34 +00:00
Add a test that a sensible error is raised when MDBTools is not found
This is the error that happens in issue #23
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import os
|
||||
import sqlite3
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -13,6 +14,19 @@ from galvani import res2sqlite
|
||||
have_mdbtools = (subprocess.call(['which', 'mdb-export'], stdout=None) == 0)
|
||||
|
||||
|
||||
@pytest.mark.skipif(have_mdbtools, reason='This tests the failure when mdbtools is not installed')
|
||||
def test_convert_Arbin_no_mdbtools(testdata_dir, tmpdir):
|
||||
"""Checks that the conversion fails with an appropriate error message."""
|
||||
res_file = os.path.join(testdata_dir, 'arbin1.res')
|
||||
sqlite_file = os.path.join(str(tmpdir), 'arbin1.s3db')
|
||||
if sys.version_info >= (3, 3):
|
||||
expected_exception = FileNotFoundError
|
||||
else:
|
||||
expected_exception = OSError
|
||||
with pytest.raises(expected_exception, match="No such file or directory: 'mdb-export'"):
|
||||
res2sqlite.convert_arbin_to_sqlite(res_file, sqlite_file)
|
||||
|
||||
|
||||
@pytest.mark.skipif(not have_mdbtools, reason='Reading the Arbin file requires MDBTools')
|
||||
@pytest.mark.parametrize('basename', ['arbin1'])
|
||||
def test_convert_Arbin_to_sqlite(testdata_dir, tmpdir, basename):
|
||||
|
||||
Reference in New Issue
Block a user