diff --git a/tests/chktex_tool_plugin/test_chktex_tool_plugin.py b/tests/chktex_tool_plugin/test_chktex_tool_plugin.py index 4fb9dd3..8a0c016 100644 --- a/tests/chktex_tool_plugin/test_chktex_tool_plugin.py +++ b/tests/chktex_tool_plugin/test_chktex_tool_plugin.py @@ -5,6 +5,7 @@ import pytest import subprocess import sys +from pathlib import Path import statick_tool from statick_tool.config import Config @@ -151,9 +152,11 @@ def test_chktex_tool_plugin_scan_oserror(mock_subprocess_check_output): issues = cttp.scan(package, "level") assert issues is None - try: - os.remove(os.path.join(os.getcwd(), "chktex.log")) - except FileNotFoundError as ex: - print(f"Error: {ex}") - except OSError as ex: - print(f"Error: {ex}") + log_file = Path("chktex.log") + if log_file.is_file(): + try: + log_file.unlink() + except FileNotFoundError as ex: + print(f"Error: {ex}") + except OSError as ex: + print(f"Error: {ex}") diff --git a/tests/lacheck_tool_plugin/test_lacheck_tool_plugin.py b/tests/lacheck_tool_plugin/test_lacheck_tool_plugin.py index f5dcdb9..8d821e8 100644 --- a/tests/lacheck_tool_plugin/test_lacheck_tool_plugin.py +++ b/tests/lacheck_tool_plugin/test_lacheck_tool_plugin.py @@ -5,6 +5,7 @@ import pytest import subprocess import sys +from pathlib import Path import statick_tool from statick_tool.config import Config @@ -145,9 +146,11 @@ def test_lacheck_tool_plugin_scan_oserror(mock_subprocess_check_output): issues = ltp.scan(package, "level") assert issues is None - try: - os.remove(os.path.join(os.getcwd(), "lacheck.log")) - except FileNotFoundError as ex: - print(f"Error: {ex}") - except OSError as ex: - print(f"Error: {ex}") + log_file = Path("lacheck.log") + if log_file.is_file(): + try: + log_file.unlink() + except FileNotFoundError as ex: + print(f"Error: {ex}") + except OSError as ex: + print(f"Error: {ex}")