From b1feb69ca96aeb73ac7a8ef0de4e47037ea209d7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 25 Dec 2021 10:30:59 +0100 Subject: [PATCH] Use Pathlib to delete testfile --- tests/optimize/test_hyperopt.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/optimize/test_hyperopt.py b/tests/optimize/test_hyperopt.py index 5e8d899c8..389cdb11e 100644 --- a/tests/optimize/test_hyperopt.py +++ b/tests/optimize/test_hyperopt.py @@ -1,5 +1,4 @@ # pragma pylint: disable=missing-docstring,W0212,C0103 -import os from datetime import datetime from pathlib import Path from unittest.mock import ANY, MagicMock @@ -192,10 +191,7 @@ def test_start_no_data(mocker, hyperopt_conf) -> None: start_hyperopt(pargs) # Cleanup since that failed hyperopt start leaves a lockfile. - try: - os.unlink(Hyperopt.get_lock_filename(hyperopt_conf)) - except Exception: - pass + Path(Hyperopt.get_lock_filename(hyperopt_conf)).unlink(missing_ok=True) def test_start_filelock(mocker, hyperopt_conf, caplog) -> None: