Catching an unhandled SystemError occurring in some tests. RE:#72

This commit is contained in:
James Douglass 2020-04-21 11:01:43 -07:00
parent ba91a876b3
commit e693f8b1f6
2 changed files with 11 additions and 4 deletions

View File

@ -174,8 +174,16 @@ def log_to_file(logfile, exclude_threads=None, logging_level=logging.NOTSET,
Returns:
``None``"""
try:
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')
formatter = logging.Formatter(log_fmt, date_fmt)

View File

@ -16,7 +16,6 @@ class CLIGUITests(unittest.TestCase):
def test_run_model(self):
"""CLI-GUI: Run a model GUI through the cli."""
from natcap.invest import cli
from natcap.invest import delineateit
parameter_set_path = os.path.join(
os.path.dirname(__file__), '..', 'data', 'invest-test-data',
'fisheries', 'spiny_lobster_belize.invs.json')