Merge remote-tracking branch 'origin/pr/6262'
This commit is contained in:
commit
24ca7b7919
|
|
@ -19,8 +19,7 @@
|
|||
|
||||
"""Fixtures to run qutebrowser in a QProcess and communicate."""
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
|
@ -505,22 +504,20 @@ class QuteProc(testprocess.Process):
|
|||
if hasattr(sys, 'frozen'):
|
||||
if profile:
|
||||
raise Exception("Can't profile with sys.frozen!")
|
||||
executable = os.path.join(os.path.dirname(sys.executable),
|
||||
'qutebrowser')
|
||||
executable = pathlib.Path(sys.executable).parent / 'qutebrowser'
|
||||
args = []
|
||||
else:
|
||||
executable = sys.executable
|
||||
if profile:
|
||||
profile_dir = os.path.join(os.getcwd(), 'prof')
|
||||
profile_dir = pathlib.Path.cwd() / 'prof'
|
||||
profile_id = '{}_{}'.format(self._instance_id,
|
||||
next(self._run_counter))
|
||||
profile_file = os.path.join(profile_dir,
|
||||
'{}.pstats'.format(profile_id))
|
||||
profile_file = profile_dir / '{}.pstats'.format(profile_id)
|
||||
try:
|
||||
os.mkdir(profile_dir)
|
||||
profile_dir.mkdir()
|
||||
except FileExistsError:
|
||||
pass
|
||||
args = [os.path.join('scripts', 'dev', 'run_profile.py'),
|
||||
args = [(pathlib.Path('scripts') / 'dev' / 'run_profile.py'),
|
||||
'--profile-tool', 'none',
|
||||
'--profile-file', profile_file]
|
||||
else:
|
||||
|
|
@ -861,21 +858,20 @@ class QuteProc(testprocess.Process):
|
|||
|
||||
def get_session(self):
|
||||
"""Save the session and get the parsed session data."""
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
session = os.path.join(tmpdir, 'session.yml')
|
||||
with tempfile.TemporaryDirectory() as tdir:
|
||||
session = pathlib.Path(tdir) / 'session.yml'
|
||||
self.send_cmd(':session-save --with-private "{}"'.format(session))
|
||||
self.wait_for(category='message', loglevel=logging.INFO,
|
||||
message='Saved session {}.'.format(session))
|
||||
with open(session, encoding='utf-8') as f:
|
||||
data = f.read()
|
||||
data = session.read_text(encoding='utf-8')
|
||||
|
||||
self._log('\nCurrent session data:\n' + data)
|
||||
return utils.yaml_load(data)
|
||||
|
||||
def get_content(self, plain=True):
|
||||
"""Get the contents of the current page."""
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
path = os.path.join(tmpdir, 'page')
|
||||
with tempfile.TemporaryDirectory() as tdir:
|
||||
path = pathlib.Path(tdir) / 'page'
|
||||
|
||||
if plain:
|
||||
self.send_cmd(':debug-dump-page --plain "{}"'.format(path))
|
||||
|
|
@ -885,8 +881,7 @@ class QuteProc(testprocess.Process):
|
|||
self.wait_for(category='message', loglevel=logging.INFO,
|
||||
message='Dumped page to {}.'.format(path))
|
||||
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
return path.read_text(encoding='utf-8')
|
||||
|
||||
def get_screenshot(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
import re
|
||||
import sys
|
||||
import json
|
||||
import os.path
|
||||
import pathlib
|
||||
import socket
|
||||
import dataclasses
|
||||
from http import HTTPStatus
|
||||
|
|
@ -171,13 +171,13 @@ class WebserverProcess(testprocess.Process):
|
|||
|
||||
def _executable_args(self):
|
||||
if hasattr(sys, 'frozen'):
|
||||
executable = os.path.join(os.path.dirname(sys.executable),
|
||||
self._script)
|
||||
executable = str(pathlib.Path(sys.executable).parent
|
||||
/ self._script)
|
||||
args = []
|
||||
else:
|
||||
executable = sys.executable
|
||||
py_file = os.path.join(os.path.dirname(__file__),
|
||||
self._script + '.py')
|
||||
py_file = str((pathlib.Path(__file__).parent
|
||||
/ self._script).with_suffix('.py'))
|
||||
args = [py_file]
|
||||
return executable, args
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ This script gets called as a QProcess from end2end/conftest.py.
|
|||
import ssl
|
||||
import sys
|
||||
import logging
|
||||
import os.path
|
||||
import pathlib
|
||||
|
||||
import flask
|
||||
|
||||
|
|
@ -62,11 +62,11 @@ def turn_off_logging():
|
|||
|
||||
|
||||
def main():
|
||||
ssl_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
|
||||
'..', 'data', 'ssl')
|
||||
ssl_dir = (pathlib.Path(__file__).parent.resolve()
|
||||
/ '..' / 'data' / 'ssl')
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
||||
context.load_cert_chain(os.path.join(ssl_dir, 'cert.pem'),
|
||||
os.path.join(ssl_dir, 'key.pem'))
|
||||
context.load_cert_chain((ssl_dir / 'cert.pem'),
|
||||
(ssl_dir / 'key.pem'))
|
||||
app.run(port=int(sys.argv[1]), debug=False, ssl_context=context)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue