Skip to content

Commit

Permalink
windows started passing, but linux failing; one quick check to see if…
Browse files Browse the repository at this point in the history
… logging.info helps:
  • Loading branch information
DLWoodruff committed Mar 30, 2024
1 parent 7c04022 commit 1629bd7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pyomo/contrib/iis/tests/test_mis.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,31 @@ def _test_mis(solver_name):
opt = pyo.SolverFactory(solver_name)

# This test seems to fail on Windows as it unlinks the tempfile, so live with it
try:
# On a Windows machine, we will not use a temp dir and just try to delete the log file
if os.name == "nt":
print("we have nt")
file_name = f"{solver_name}_mis.log"
logger = logging.getLogger(f"test_mis_{solver_name}")
fh = logging.FileHandler(file_name)
fh.setLevel(logging.DEBUG)
logger.addHandler(fh)

mis.compute_infeasibility_explanation(m, opt, logger=logger)
_check_output(file_name)

else: # not windows
with TempfileManager.new_context() as tmpmgr:
print("start")
tmp_path = tmpmgr.mkdtemp()
file_name = os.path.join(tmp_path, f"{solver_name}_mis.log")
logger = logging.getLogger(f"test_mis_{solver_name}")
###logger.setLevel(logging.INFO)
# create file handler which logs even debug messages
logger.setlevel(logging.INFO)
fh = logging.FileHandler(file_name)
fh.setLevel(logging.DEBUG)
logger.addHandler(fh)

mis.compute_infeasibility_explanation(m, opt, logger=logger)
_check_output(file_name)

except PermissionError:
print("PerimssionError allowed for log file during test (Windows)")


if __name__ == "__main__":
unittest.main()

0 comments on commit 1629bd7

Please sign in to comment.