Add test for :print --pdf
This commit is contained in:
parent
62ae793a24
commit
6b2b096f3c
@ -332,6 +332,7 @@ class CommandDispatcher:
|
||||
printer = QPrinter()
|
||||
printer.setOutputFileName(pdf)
|
||||
tab.print(printer)
|
||||
log.misc.debug("Print to file: {}".format(pdf))
|
||||
else:
|
||||
diag = QPrintDialog()
|
||||
diag.setAttribute(Qt.WA_DeleteOnClose)
|
||||
|
@ -179,7 +179,7 @@ def set_setting(quteproc, httpbin, sect, opt, value):
|
||||
|
||||
|
||||
@bdd.when(bdd.parsers.parse("I run {command}"))
|
||||
def run_command(quteproc, httpbin, command):
|
||||
def run_command(quteproc, httpbin, tmpdir, command):
|
||||
"""Run a qutebrowser command.
|
||||
|
||||
The suffix "with count ..." can be used to pass a count to the command.
|
||||
@ -199,6 +199,7 @@ def run_command(quteproc, httpbin, command):
|
||||
|
||||
command = command.replace('(port)', str(httpbin.port))
|
||||
command = command.replace('(testdata)', utils.abs_datapath())
|
||||
command = command.replace('(tmpdir)', str(tmpdir))
|
||||
|
||||
quteproc.send_cmd(command, count=count, invalid=invalid)
|
||||
|
||||
|
@ -339,6 +339,13 @@ Feature: Various utility commands.
|
||||
And I run :debug-pyeval QApplication.instance().activeModalWidget().close()
|
||||
Then no crash should happen
|
||||
|
||||
Scenario: print pdf
|
||||
Given a new tmpdir
|
||||
When I open data/hello.txt
|
||||
And I run :print --pdf (tmpdir)/hello.pdf
|
||||
And I wait for "Print to file: *" in the log or skip the test
|
||||
Then the file hello.pdf should exist in the tmpdir
|
||||
|
||||
# :pyeval
|
||||
|
||||
Scenario: Running :pyeval
|
||||
|
@ -73,3 +73,14 @@ def check_cookie(quteproc, name, value):
|
||||
data = json.loads(content)
|
||||
print(data)
|
||||
assert data['cookies'][name] == value
|
||||
|
||||
|
||||
@bdd.given(bdd.parsers.parse('a new tmpdir'))
|
||||
def tmpdir(tmpdir_factory):
|
||||
return tmpdir_factory.mktemp('tmpdir')
|
||||
|
||||
|
||||
@bdd.then(bdd.parsers.parse('the file {filename} should exist in the tmpdir'))
|
||||
def file_exists(quteproc, tmpdir, filename):
|
||||
path = tmpdir / filename
|
||||
assert os.path.exists(str(path))
|
||||
|
Loading…
Reference in New Issue
Block a user