def test_maybe_flock(self):
        with mock.patch("paasta_tools.utils.fcntl") as mock_fcntl:
            fw = utils.FileLogWriter("/dev/null", flock=True)
            mock_file = mock.Mock()
            with fw.maybe_flock(mock_file):
                mock_fcntl.flock.assert_called_once_with(mock_file, mock_fcntl.LOCK_EX)
                mock_fcntl.flock.reset_mock()

            mock_fcntl.flock.assert_called_once_with(mock_file, mock_fcntl.LOCK_UN)
Make sure we flock and unflock when flock=True
dataset/ETHPy150Open Yelp/paasta/tests/test_utils.py/TestFileLogWriter.test_maybe_flock