parent
47b9ea1f88
commit
751b62e344
@ -18,18 +18,3 @@
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""The qutebrowser test suite."""
|
||||
|
||||
import atexit
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
from qutebrowser.test import log
|
||||
|
||||
# We create a singleton QApplication here.
|
||||
|
||||
qApp = QApplication([])
|
||||
qApp.setApplicationName('qutebrowser')
|
||||
qApp.processEvents()
|
||||
atexit.register(qApp.processEvents)
|
||||
atexit.register(qApp.quit)
|
||||
log.init()
|
||||
|
32
qutebrowser/test/conftest.py
Normal file
32
qutebrowser/test/conftest.py
Normal file
@ -0,0 +1,32 @@
|
||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
# Copyright 2014-2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""The qutebrowser test suite contest file."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope='session', autouse=True)
|
||||
def app_and_logging(qapp):
|
||||
"""
|
||||
Initializes our logging system and ensures that a QApplication is created
|
||||
and used by all tests.
|
||||
"""
|
||||
from .log import init
|
||||
init()
|
@ -26,12 +26,13 @@ import shutil
|
||||
import unittest
|
||||
import tempfile
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
from qutebrowser.utils import standarddir
|
||||
from qutebrowser.test import helpers, qApp
|
||||
from qutebrowser.test import helpers
|
||||
|
||||
|
||||
class GetStandardDirLinuxTests(unittest.TestCase):
|
||||
|
||||
"""Tests for standarddir under Linux.
|
||||
|
||||
Attributes:
|
||||
@ -41,8 +42,8 @@ class GetStandardDirLinuxTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.temp_dir = tempfile.mkdtemp()
|
||||
self.old_name = qApp.applicationName()
|
||||
qApp.setApplicationName('qutebrowser')
|
||||
self.old_name = QApplication.instance().applicationName()
|
||||
QApplication.instance().setApplicationName('qutebrowser')
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith("linux"), "requires Linux")
|
||||
def test_data_explicit(self):
|
||||
@ -97,12 +98,11 @@ class GetStandardDirLinuxTests(unittest.TestCase):
|
||||
self.assertEqual(standarddir.cache(), expected)
|
||||
|
||||
def tearDown(self):
|
||||
qApp.setApplicationName(self.old_name)
|
||||
QApplication.instance().setApplicationName(self.old_name)
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
||||
|
||||
class GetStandardDirWindowsTests(unittest.TestCase):
|
||||
|
||||
"""Tests for standarddir under Windows.
|
||||
|
||||
Attributes:
|
||||
@ -110,13 +110,13 @@ class GetStandardDirWindowsTests(unittest.TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.old_name = qApp.applicationName()
|
||||
self.old_name = QApplication.instance().applicationName()
|
||||
# We can't store the files in a temp dir, so we don't chose qutebrowser
|
||||
qApp.setApplicationName('qutebrowser_test')
|
||||
QApplication.instance().setApplicationName('qutebrowser_test')
|
||||
standarddir.init(None)
|
||||
|
||||
def tearDown(self):
|
||||
qApp.setApplicationName(self.old_name)
|
||||
QApplication.instance().setApplicationName(self.old_name)
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
|
||||
def test_data(self):
|
||||
|
Loading…
Reference in New Issue
Block a user