Don't add username to FIFO name on Linux.

The runtime directory already has a qutebrowser subdir.
This commit is contained in:
Florian Bruhin 2015-09-08 21:27:46 +02:00
parent 3573b57130
commit 4daa7e6979
2 changed files with 9 additions and 11 deletions

View File

@ -56,12 +56,11 @@ def _get_socketname(basedir, legacy=False):
if sys.platform.startswith('linux'):
target_dir = standarddir.runtime()
parts = ['qutebrowser-ipc']
else: # pragma: no cover
# OS X or other Unix
parts = ['ipc']
target_dir = standarddir.temp()
parts = ['ipc']
if basedir_md5 is not None:
parts.append(basedir_md5)
return os.path.join(target_dir, '-'.join(parts))

View File

@ -176,6 +176,11 @@ class TestSocketName:
('/x', 'qutebrowser-{}-{}'.format(getpass.getuser(), MD5)),
]
POSIX_TESTS = [
(None, 'ipc'),
('/x', 'ipc-{}'.format(MD5)),
]
@pytest.mark.parametrize('basedir, expected', LEGACY_TESTS)
def test_legacy(self, basedir, expected):
socketname = ipc._get_socketname(basedir, legacy=True)
@ -188,21 +193,15 @@ class TestSocketName:
assert socketname == expected
@pytest.mark.osx
@pytest.mark.parametrize('basedir, expected', [
(None, 'ipc'),
('/x', 'ipc-{}'.format(MD5)),
])
@pytest.mark.parametrize('basedir, expected', POSIX_TESTS)
def test_os_x(self, basedir, expected):
socketname = ipc._get_socketname(basedir)
parts = os.path.split(socketname)
parts = socketname.split(os.sep)
assert parts[-2] == 'qutebrowser_test'
assert parts[-1] == expected
@pytest.mark.linux
@pytest.mark.parametrize('basedir, expected', [
(None, 'qutebrowser-ipc'),
('/x', 'qutebrowser-ipc-{}'.format(MD5)),
])
@pytest.mark.parametrize('basedir, expected', POSIX_TESTS)
def test_linux(self, basedir, fake_runtime_dir, expected):
socketname = ipc._get_socketname(basedir)
expected_path = str(fake_runtime_dir / 'qutebrowser_test' / expected)