Skip to content

Commit

Permalink
Add support for python 3.5
Browse files Browse the repository at this point in the history
Use Path.open() instead of open()
Update test to use the mocked assert_called_once()
  • Loading branch information
jjnicola committed May 14, 2020
1 parent 47b907d commit de5860e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ospd_openvas/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def acquire_lock(self) -> "LockFile":
parent_dir = self._lock_file_path.parent
parent_dir.mkdir(parents=True, exist_ok=True)

self._fd = open(self._lock_file_path, 'w')
self._fd = self._lock_file_path.open('w')
except PermissionError as e:
logger.error(
"Failed to create lock file %s. %s",
Expand Down
5 changes: 3 additions & 2 deletions tests/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from unittest.mock import patch, MagicMock
from ospd_openvas.lock import LockFile
from .helper import assert_called_once


class LockFileTestCase(unittest.TestCase):
Expand Down Expand Up @@ -55,7 +56,7 @@ def test_already_locked(self, mock_logger):
lock_file = LockFile(lock_file_path)
lock_file.acquire_lock()
self.assertFalse(lock_file.has_lock())
mock_logger.error.assert_called_once()
assert_called_once(mock_logger.error)

lock_file_aux.release_lock()

Expand All @@ -81,7 +82,7 @@ def test_create_paren_dirs_fail(self, mock_logger):
lock_file.acquire_lock()
self.assertFalse(lock_file.has_lock())

mock_logger.error.assert_called_once()
assert_called_once(mock_logger.error)

def test_context_manager(self):
lock_file_path = self.temp_dir / 'test.lock'
Expand Down

0 comments on commit de5860e

Please sign in to comment.