Add standarddir.download() tests.
This commit is contained in:
parent
df095daf24
commit
cc052a539f
@ -39,7 +39,7 @@ def config():
|
|||||||
if not overridden:
|
if not overridden:
|
||||||
path = _writable_location(typ)
|
path = _writable_location(typ)
|
||||||
appname = QCoreApplication.instance().applicationName()
|
appname = QCoreApplication.instance().applicationName()
|
||||||
if path.split(os.sep)[-1] != appname:
|
if path.split(os.sep)[-1] != appname: # pragma: no branch
|
||||||
# WORKAROUND - see
|
# WORKAROUND - see
|
||||||
# https://bugreports.qt.io/browse/QTBUG-38872
|
# https://bugreports.qt.io/browse/QTBUG-38872
|
||||||
path = os.path.join(path, appname)
|
path = os.path.join(path, appname)
|
||||||
|
@ -112,14 +112,20 @@ class TestStandardDir:
|
|||||||
])
|
])
|
||||||
@pytest.mark.linux
|
@pytest.mark.linux
|
||||||
def test_linux_explicit(self, monkeypatch, tmpdir, func, varname):
|
def test_linux_explicit(self, monkeypatch, tmpdir, func, varname):
|
||||||
"""Test dirs with XDG_*_HOME explicitly set."""
|
"""Test dirs with XDG environment variables explicitly set.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
func: The function to test.
|
||||||
|
varname: The environment variable which should be set.
|
||||||
|
"""
|
||||||
monkeypatch.setenv(varname, str(tmpdir))
|
monkeypatch.setenv(varname, str(tmpdir))
|
||||||
assert func() == str(tmpdir / 'qute_test')
|
assert func() == str(tmpdir / 'qute_test')
|
||||||
|
|
||||||
@pytest.mark.parametrize('func, subdirs', [
|
@pytest.mark.parametrize('func, subdirs', [
|
||||||
(standarddir.data, ['.local', 'share']),
|
(standarddir.data, ['.local', 'share', 'qute_test']),
|
||||||
(standarddir.config, ['.config']),
|
(standarddir.config, ['.config', 'qute_test']),
|
||||||
(standarddir.cache, ['.cache']),
|
(standarddir.cache, ['.cache', 'qute_test']),
|
||||||
|
(standarddir.download, ['Downloads']),
|
||||||
])
|
])
|
||||||
@pytest.mark.linux
|
@pytest.mark.linux
|
||||||
def test_linux_normal(self, monkeypatch, tmpdir, func, subdirs):
|
def test_linux_normal(self, monkeypatch, tmpdir, func, subdirs):
|
||||||
@ -127,12 +133,13 @@ class TestStandardDir:
|
|||||||
monkeypatch.setenv('HOME', str(tmpdir))
|
monkeypatch.setenv('HOME', str(tmpdir))
|
||||||
for var in ('DATA', 'CONFIG', 'CACHE'):
|
for var in ('DATA', 'CONFIG', 'CACHE'):
|
||||||
monkeypatch.delenv('XDG_{}_HOME'.format(var), raising=False)
|
monkeypatch.delenv('XDG_{}_HOME'.format(var), raising=False)
|
||||||
assert func() == str(tmpdir.join(*subdirs) / 'qute_test')
|
assert func() == str(tmpdir.join(*subdirs))
|
||||||
|
|
||||||
@pytest.mark.parametrize('func, elems, expected', [
|
@pytest.mark.parametrize('func, elems, expected', [
|
||||||
(standarddir.data, 2, ['qute_test', 'data']),
|
(standarddir.data, 2, ['qute_test', 'data']),
|
||||||
(standarddir.config, 1, ['qute_test']),
|
(standarddir.config, 1, ['qute_test']),
|
||||||
(standarddir.cache, 2, ['qute_test', 'cache']),
|
(standarddir.cache, 2, ['qute_test', 'cache']),
|
||||||
|
(standarddir.download, 1, ['Downloads']),
|
||||||
])
|
])
|
||||||
@pytest.mark.windows
|
@pytest.mark.windows
|
||||||
def test_windows(self, func, elems, expected):
|
def test_windows(self, func, elems, expected):
|
||||||
|
Loading…
Reference in New Issue
Block a user