예제 #1
0
    def test_prepare_save_no_config(self, mocker):
        """Test if _prepare_save doesn't create a None config dir."""
        os_mock = mocker.patch('qutebrowser.misc.lineparser.os')
        os_mock.path.exists.return_value = True

        lineparser = lineparsermod.BaseLineParser(None, self.FILENAME)
        assert not lineparser._prepare_save()
        assert not os_mock.makedirs.called
예제 #2
0
    def test_binary(self, mocker):
        """Test if _open and _write correctly handle binary files."""
        open_mock = mock.mock_open()
        mocker.patch('builtins.open', open_mock)

        testdata = b'\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(b'\n')])
예제 #3
0
 def lineparser(self):
     """Fixture providing a BaseLineParser."""
     return lineparsermod.BaseLineParser(self.CONFDIR, self.FILENAME)
예제 #4
0
 def setUp(self):
     self._confdir = "this really doesn't matter"
     self._fname = "and neither does this"
     self._lineparser = lineparser.BaseLineParser(
         self._confdir, self._fname)