Fixed joinpath plus cleaner path
This commit is contained in:
parent
66cfa15c37
commit
f2f2acd5ba
|
|
@ -56,8 +56,8 @@ def pytest_unconfigure(config):
|
|||
if config.getoption('--qute-profile-subprocs'):
|
||||
stats = pstats.Stats()
|
||||
for fn in pathlib.Path('prof').iterdir():
|
||||
stats.add(pathlib.Path('prof').joinpath(fn))
|
||||
stats.dump_stats(pathlib.Path('prof').joinpath('combined.pstats'))
|
||||
stats.add((pathlib.Path('prof') / fn))
|
||||
stats.dump_stats((pathlib.Path('prof') / 'combined.pstats'))
|
||||
|
||||
|
||||
def _get_version_tag(tag):
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ def test_parent_with_slash(dir_layout, quteproc):
|
|||
|
||||
def test_parent_in_root_dir(dir_layout, quteproc):
|
||||
# This actually works on windows
|
||||
root_path = pathlib.Path.root
|
||||
root_path = str(pathlib.Path('/'))
|
||||
urlstr = QUrl.fromLocalFile(root_path).toString(QUrl.FullyEncoded)
|
||||
quteproc.open_url(urlstr)
|
||||
page = parse(quteproc)
|
||||
|
|
@ -194,7 +194,7 @@ def test_enter_folder_smoke(dir_layout, quteproc):
|
|||
quteproc.send_cmd(':hint all normal')
|
||||
# a is the parent link, s is the first listed folder/file
|
||||
quteproc.send_cmd(':hint-follow s')
|
||||
expected_url = urlutils.file_url(dir_layout.path('folder0'))
|
||||
expected_url = urlutils.file_url(str(dir_layout.path('folder0')))
|
||||
quteproc.wait_for_load_finished_url(expected_url)
|
||||
page = parse(quteproc)
|
||||
assert page.path == dir_layout.path('folder0')
|
||||
|
|
@ -204,7 +204,7 @@ def test_enter_folder_smoke(dir_layout, quteproc):
|
|||
def test_enter_folder(dir_layout, quteproc, folder):
|
||||
quteproc.open_url(dir_layout.file_url())
|
||||
quteproc.click_element_by_text(text=folder)
|
||||
expected_url = urlutils.file_url(dir_layout.path(folder))
|
||||
expected_url = urlutils.file_url(str(dir_layout.path(folder)))
|
||||
quteproc.wait_for_load_finished_url(expected_url)
|
||||
page = parse(quteproc)
|
||||
assert page.path == dir_layout.path(folder)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ from qutebrowser.utils import utils
|
|||
|
||||
def collect_tests():
|
||||
basedir = pathlib.Path(__file__).parent
|
||||
datadir = pathlib.Path(basedir).joinpath('data', 'hints', 'html')
|
||||
datadir = basedir / 'data' / 'hints' / 'html'
|
||||
files = [str(f.name) for f in datadir.iterdir() if f.name != 'README.md']
|
||||
return files
|
||||
|
||||
|
|
@ -54,8 +54,8 @@ class InvalidFile(Exception):
|
|||
|
||||
def _parse_file(test_name):
|
||||
"""Parse the given HTML file."""
|
||||
file_path = pathlib.Path(__file__).parent.resolve().joinpath(
|
||||
'data', 'hints', 'html', test_name)
|
||||
file_path = (pathlib.Path(__file__).parent.resolve()
|
||||
/ 'data' / 'hints' / 'html' / test_name)
|
||||
with file_path.open('r', encoding='utf-8') as html:
|
||||
soup = bs4.BeautifulSoup(html, 'html.parser')
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ def temp_basedir_env(tmp_path, short_tmpdir):
|
|||
]
|
||||
|
||||
state_file = data_dir / 'qutebrowser' / 'state'
|
||||
state_file.parent.mkdir(exist_ok=True, parents=True)
|
||||
state_file.touch(exist_ok=True)
|
||||
state_file.write_text('\n'.join(lines), encoding='utf-8')
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import pytest
|
|||
|
||||
def collect_tests():
|
||||
basedir = pathlib.Path(__file__).parent
|
||||
datadir = basedir.joinpath('data', 'downloads', 'mhtml')
|
||||
datadir = basedir / 'data' / 'downloads' / 'mhtml'
|
||||
files = [x.name for x in datadir.iterdir()]
|
||||
return files
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ def download_dir(tmp_path, pytestconfig):
|
|||
|
||||
|
||||
def _test_mhtml_requests(test_dir, test_path, server):
|
||||
with open(pathlib.Path(test_dir / 'requests'), encoding='utf-8') as f:
|
||||
with (test_dir / 'requests').open(encoding='utf-8') as f:
|
||||
expected_requests = []
|
||||
for line in f:
|
||||
if line.startswith('#'):
|
||||
|
|
@ -107,18 +107,18 @@ def test_mhtml(request, test_name, download_dir, quteproc, server):
|
|||
quteproc.set_setting('downloads.location.directory', download_dir.location)
|
||||
quteproc.set_setting('downloads.location.prompt', 'false')
|
||||
|
||||
test_dir = pathlib.Path(__file__).parent.resolve().joinpath(
|
||||
'data', 'downloads', 'mhtml', test_name)
|
||||
test_dir = (pathlib.Path(__file__).parent.resolve()
|
||||
/ 'data' / 'downloads' / 'mhtml' / test_name)
|
||||
test_path = 'data/downloads/mhtml/{}'.format(test_name)
|
||||
|
||||
url_path = '{}/{}.html'.format(test_path, test_name)
|
||||
quteproc.open_path(url_path)
|
||||
|
||||
download_dest = pathlib.Path(download_dir.location).joinpath(
|
||||
'{}-downloaded.mht'.format(test_name))
|
||||
download_dest = (pathlib.Path(download_dir.location)
|
||||
/ '{}-downloaded.mht'.format(test_name))
|
||||
|
||||
# Wait for favicon.ico to be loaded if there is one
|
||||
if pathlib.Path(test_dir).joinpath('favicon.png').exists():
|
||||
if (test_dir / 'favicon.png').exists():
|
||||
server.wait_for(path='/{}/favicon.png'.format(test_path))
|
||||
|
||||
# Discard all requests that were necessary to display the page
|
||||
|
|
@ -132,7 +132,7 @@ def test_mhtml(request, test_name, download_dir, quteproc, server):
|
|||
return
|
||||
|
||||
filename = test_name + '.mht'
|
||||
expected_file = pathlib.Path(test_dir).joinpath(filename)
|
||||
expected_file = test_dir / filename
|
||||
|
||||
download_dir.compare_mhtml(expected_file)
|
||||
_test_mhtml_requests(test_dir, test_path, server)
|
||||
|
|
|
|||
Loading…
Reference in New Issue