Catching an unhandled SystemError occurring in some tests. RE:#72
This commit is contained in:
parent
ba91a876b3
commit
e693f8b1f6
|
@ -174,8 +174,16 @@ def log_to_file(logfile, exclude_threads=None, logging_level=logging.NOTSET,
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``None``"""
|
``None``"""
|
||||||
if os.path.exists(logfile):
|
try:
|
||||||
LOGGER.warn('Logfile %s exists and will be overwritten', logfile)
|
if os.path.exists(logfile):
|
||||||
|
LOGGER.warn('Logfile %s exists and will be overwritten', logfile)
|
||||||
|
except SystemError:
|
||||||
|
# This started happening in Windows tests:
|
||||||
|
# SystemError: <built-in function stat> returned NULL without
|
||||||
|
# setting an error
|
||||||
|
# Looking at https://bugs.python.org/issue28040#msg276223, this might
|
||||||
|
# be a low-level python error.
|
||||||
|
pass
|
||||||
|
|
||||||
handler = logging.FileHandler(logfile, 'w', encoding='UTF-8')
|
handler = logging.FileHandler(logfile, 'w', encoding='UTF-8')
|
||||||
formatter = logging.Formatter(log_fmt, date_fmt)
|
formatter = logging.Formatter(log_fmt, date_fmt)
|
||||||
|
@ -459,7 +467,7 @@ def build_lookup_from_csv(
|
||||||
table = pandas.read_csv(
|
table = pandas.read_csv(
|
||||||
table_path, sep=None, engine='python', encoding=encoding)
|
table_path, sep=None, engine='python', encoding=encoding)
|
||||||
header_row = list(table)
|
header_row = list(table)
|
||||||
|
|
||||||
if to_lower:
|
if to_lower:
|
||||||
key_field = key_field.lower()
|
key_field = key_field.lower()
|
||||||
header_row = [
|
header_row = [
|
||||||
|
|
|
@ -16,7 +16,6 @@ class CLIGUITests(unittest.TestCase):
|
||||||
def test_run_model(self):
|
def test_run_model(self):
|
||||||
"""CLI-GUI: Run a model GUI through the cli."""
|
"""CLI-GUI: Run a model GUI through the cli."""
|
||||||
from natcap.invest import cli
|
from natcap.invest import cli
|
||||||
from natcap.invest import delineateit
|
|
||||||
parameter_set_path = os.path.join(
|
parameter_set_path = os.path.join(
|
||||||
os.path.dirname(__file__), '..', 'data', 'invest-test-data',
|
os.path.dirname(__file__), '..', 'data', 'invest-test-data',
|
||||||
'fisheries', 'spiny_lobster_belize.invs.json')
|
'fisheries', 'spiny_lobster_belize.invs.json')
|
||||||
|
|
Loading…
Reference in New Issue