diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-05-28 16:50:58 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-05-28 16:59:08 +0200 |
commit | ff0fe25ebb21f00dd8e921d1e1a0b17ae8d6f051 (patch) | |
tree | 88848341ef3d6323f5c5bf5917d4be321916170a | |
parent | 98b4c80634f2415bfec9a02ceec643d80fc2622b (diff) | |
download | qutebrowser-ff0fe25ebb21f00dd8e921d1e1a0b17ae8d6f051.tar.gz qutebrowser-ff0fe25ebb21f00dd8e921d1e1a0b17ae8d6f051.zip |
Fix tests/lint
We need to set XDG_RUNTIME_DIR properly in the tests so that the log is empty.
(cherry picked from commit 1830f784df18057f5e07a59256cc73b5fea91a86)
-rw-r--r-- | qutebrowser/utils/log.py | 2 | ||||
-rw-r--r-- | tests/end2end/test_invocations.py | 21 |
2 files changed, 14 insertions, 9 deletions
diff --git a/qutebrowser/utils/log.py b/qutebrowser/utils/log.py index 2fb64eddd..9cd07e2e3 100644 --- a/qutebrowser/utils/log.py +++ b/qutebrowser/utils/log.py @@ -33,7 +33,7 @@ import json import inspect import argparse from typing import (TYPE_CHECKING, Any, Iterator, Mapping, MutableSequence, - Optional, Set, Tuple, Union, cast) + Optional, Set, Tuple, Union) from PyQt5 import QtCore # Optional imports diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index 076ebb2bd..bf3d65ae6 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -55,7 +55,16 @@ def _base_args(config): @pytest.fixture -def temp_basedir_env(tmp_path, short_tmpdir): +def runtime_tmpdir(short_tmpdir): + """A directory suitable for XDG_RUNTIME_DIR.""" + runtime_dir = short_tmpdir / 'rt' + runtime_dir.ensure(dir=True) + runtime_dir.chmod(0o700) + return runtime_dir + + +@pytest.fixture +def temp_basedir_env(tmp_path, runtime_tmpdir): """Return a dict of environment variables that fakes --temp-basedir. We can't run --basedir or --temp-basedir for some tests, so we mess with @@ -63,12 +72,8 @@ def temp_basedir_env(tmp_path, short_tmpdir): """ data_dir = tmp_path / 'data' config_dir = tmp_path / 'config' - runtime_dir = short_tmpdir / 'rt' cache_dir = tmp_path / 'cache' - runtime_dir.ensure(dir=True) - runtime_dir.chmod(0o700) - lines = [ '[general]', 'quickstart-done = 1', @@ -83,7 +88,7 @@ def temp_basedir_env(tmp_path, short_tmpdir): env = { 'XDG_DATA_HOME': str(data_dir), 'XDG_CONFIG_HOME': str(config_dir), - 'XDG_RUNTIME_DIR': str(runtime_dir), + 'XDG_RUNTIME_DIR': str(runtime_tmpdir), 'XDG_CACHE_HOME': str(cache_dir), } return env @@ -745,12 +750,12 @@ def test_unavailable_backend(request, quteproc_new): line.expected = True -def test_json_logging_without_debug(request, quteproc_new): +def test_json_logging_without_debug(request, quteproc_new, runtime_tmpdir): args = _base_args(request.config) + ['--temp-basedir', ':quit'] args.remove('--debug') args.remove('about:blank') # interfers with :quit at the end quteproc_new.exit_expected = True - quteproc_new.start(args) + quteproc_new.start(args, env={'XDG_RUNTIME_DIR': str(runtime_tmpdir)}) assert not quteproc_new.is_running() assert not quteproc_new.captured_log |