Skip to content

Commit

Permalink
Switch from os module to pathlib/Path for checking/removing test arti…
Browse files Browse the repository at this point in the history
…fact files.
  • Loading branch information
tdenewiler committed Sep 3, 2024
1 parent b80f0e6 commit 3155731
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
15 changes: 9 additions & 6 deletions tests/chktex_tool_plugin/test_chktex_tool_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import subprocess
import sys
from pathlib import Path

import statick_tool
from statick_tool.config import Config
Expand Down Expand Up @@ -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}")
15 changes: 9 additions & 6 deletions tests/lacheck_tool_plugin/test_lacheck_tool_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import subprocess
import sys
from pathlib import Path

import statick_tool
from statick_tool.config import Config
Expand Down Expand Up @@ -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}")

0 comments on commit 3155731

Please sign in to comment.