Skip to content

Commit

Permalink
On windows we are just going to have to leave a log file from the test
Browse files Browse the repository at this point in the history
  • Loading branch information
DLWoodruff committed Mar 30, 2024
1 parent daeed6e commit ce6bac4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pyomo/contrib/iis/tests/test_mis.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,23 @@ def _test_mis(solver_name):
# 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"
file_name = f"_test_mis_{solver_name}.log"
logger = logging.getLogger(f"test_mis_{solver_name}")
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)
# os.remove(file_name) cannot remove it on Windows. Still in use.

else: # not windows
with TempfileManager.new_context() as tmpmgr:
tmp_path = tmpmgr.mkdtemp()
file_name = os.path.join(tmp_path, f"{solver_name}_mis.log")
file_name = os.path.join(tmp_path, f"_test_mis_{solver_name}.log")
logger = logging.getLogger(f"test_mis_{solver_name}")
logger.setlevel(logging.INFO)
logger.setLevel(logging.INFO)
fh = logging.FileHandler(file_name)
fh.setLevel(logging.DEBUG)
logger.addHandler(fh)
Expand Down

0 comments on commit ce6bac4

Please sign in to comment.