Exemplo n.º 1
0
    def test_lock_helper(self, open_mock):
        expect_path = '/path/to/some/file.txt.lck'
        expect_flags = os.O_CREAT | os.O_EXCL | os.O_WRONLY
        expect_mode = 0o600

        sut = _Lockfile.open('/path/to/some/file.txt.lck')

        open_mock.assert_called_once_with(expect_path, expect_flags, expect_mode)

        unlink_mock = Mock()
        close_mock = Mock()
        sut.close(os_unlink=unlink_mock, os_close=close_mock)

        unlink_mock.assert_called_once_with(expect_path)
        close_mock.assert_called_once_with(99)
Exemplo n.º 2
0
 def test_lock_helper_enoent(self, open_mock):
     with ExpectedException(LockError):
         sut = _Lockfile.open('/path/to/some/file.txt.lck')