From 2df971a79ccad5a07fc59e1c3a208f3af832b0a8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 9 Sep 2016 18:38:52 +0200 Subject: [PATCH] Move short_tmpdir fixture to conftest.py --- tests/helpers/fixtures.py | 9 +++++++++ tests/unit/misc/test_ipc.py | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 0db94add2..dd55111a9 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -27,6 +27,7 @@ See https://pytest.org/latest/fixture.html import sys import collections +import tempfile import itertools import textwrap import unittest.mock @@ -34,6 +35,7 @@ import types import os import pytest +import py.path # pylint: disable=no-name-in-module import helpers.stubs as stubsmod from qutebrowser.config import config @@ -470,3 +472,10 @@ def redirect_xdg_data(data_tmpdir, monkeypatch): we need to set the environment variable to redirect data access. """ monkeypatch.setenv('XDG_DATA_HOME', str(data_tmpdir)) + + +@pytest.fixture() +def short_tmpdir(): + """A short temporary directory for a XDG_RUNTIME_DIR.""" + with tempfile.TemporaryDirectory() as tdir: + yield py.path.local(tdir) # pylint: disable=no-member diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py index 5aca3af30..9b185f764 100644 --- a/tests/unit/misc/test_ipc.py +++ b/tests/unit/misc/test_ipc.py @@ -26,12 +26,10 @@ import collections import logging import json import hashlib -import tempfile import subprocess from unittest import mock import pytest -import py.path # pylint: disable=no-name-in-module from PyQt5.QtCore import pyqtSignal, QObject from PyQt5.QtNetwork import QLocalServer, QLocalSocket, QAbstractSocket from PyQt5.QtTest import QSignalSpy @@ -45,12 +43,6 @@ from helpers import stubs pytestmark = pytest.mark.usefixtures('qapp') -@pytest.fixture() -def short_tmpdir(): - with tempfile.TemporaryDirectory() as tdir: - yield py.path.local(tdir) # pylint: disable=no-member - - @pytest.fixture(autouse=True) def shutdown_server(): """If ipc.send_or_listen was called, make sure to shut server down."""