'Test if _open and _write correctly handle binary files.'

def test_binary(self, mocker):

    open_mock = mock.mock_open()
    mocker.patch('builtins.open', open_mock)
    testdata = '\xf0\xff'
    lineparser = lineparsermod.BaseLineParser(self.CONFDIR, self.FILENAME, binary=True)
    with lineparser._open('r') as f:
        lineparser._write(f, [testdata])
    open_mock.assert_called_once_with(os.path.join(self.CONFDIR, self.FILENAME), 'rb')
    open_mock().write.assert_has_calls([mock.call(testdata), mock.call('\n')])
