summaryrefslogtreecommitdiff
path: root/tests/end2end/fixtures/quteprocess.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-03-23 17:22:25 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-03-23 17:22:25 +0100
commit24ca7b7919f08cbef5578d83860f40553513ddae (patch)
tree4e375d263c5cad2f5064456b0cbdbeaa9172af96 /tests/end2end/fixtures/quteprocess.py
parent4e9adf85b55070de63389004be4de213496742a8 (diff)
parente444e3c9f8f5713890fccf0f2dd479fad3a955e9 (diff)
downloadqutebrowser-24ca7b7919f08cbef5578d83860f40553513ddae.tar.gz
qutebrowser-24ca7b7919f08cbef5578d83860f40553513ddae.zip
Merge remote-tracking branch 'origin/pr/6262'
Diffstat (limited to 'tests/end2end/fixtures/quteprocess.py')
-rw-r--r--tests/end2end/fixtures/quteprocess.py29
1 files changed, 12 insertions, 17 deletions
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index e998e0a1a..dcf7e2762 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -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,