Change clipboard mocking
This commit is contained in:
parent
30d3612a17
commit
537aa22d64
@ -510,11 +510,13 @@ def sanitize_filename(name, replacement='_'):
|
||||
|
||||
def set_clipboard(data, selection=False):
|
||||
"""Set the clipboard to some given data."""
|
||||
global fake_clipboard
|
||||
if selection and not supports_selection():
|
||||
raise SelectionUnsupportedError
|
||||
if log_clipboard:
|
||||
what = 'primary selection' if selection else 'clipboard'
|
||||
log.misc.debug("Setting fake {}: {}".format(what, json.dumps(data)))
|
||||
fake_clipboard = data
|
||||
else:
|
||||
mode = QClipboard.Selection if selection else QClipboard.Clipboard
|
||||
QApplication.clipboard().setText(data, mode=mode)
|
||||
|
@ -599,7 +599,7 @@ def check_open_tabs(quteproc, request, tabs):
|
||||
r'contain "(?P<content>.*)"'))
|
||||
def clipboard_contains(quteproc, server, what, content):
|
||||
expected = content.replace('(port)', str(server.port))
|
||||
expected = expected.replace('\\n', '\n')
|
||||
expected = expected.replace('\\n', os.linesep)
|
||||
quteproc.wait_for(message='Setting fake {}: {}'.format(
|
||||
what, json.dumps(expected)))
|
||||
|
||||
|
@ -651,6 +651,7 @@ class TestGetSetClipboard:
|
||||
autospec=True)
|
||||
clipboard = m()
|
||||
clipboard.text.return_value = 'mocked clipboard text'
|
||||
mocker.patch('qutebrowser.utils.utils.fake_clipboard', None)
|
||||
return clipboard
|
||||
|
||||
def test_set(self, clipboard_mock, caplog):
|
||||
|
Loading…
Reference in New Issue
Block a user