summaryrefslogtreecommitdiff
path: root/tests/unit/utils/test_utils.py
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2017-03-08 09:25:46 +0100
committerFlorian Bruhin <git@the-compiler.org>2017-03-08 09:25:46 +0100
commit7ba01e67644d531b77315cdb4bda89f9a9811d39 (patch)
tree470afd15ca8fd9991c43ba8d3e9d445fe8634ab4 /tests/unit/utils/test_utils.py
parentf86f9cd92a6c992a3a2f8dccd631ea3afb3a9413 (diff)
downloadqutebrowser-7ba01e67644d531b77315cdb4bda89f9a9811d39.tar.gz
qutebrowser-7ba01e67644d531b77315cdb4bda89f9a9811d39.zip
Get rid of utils.actute_warning
Only Ubuntu Trusty still uses Qt < 5.3, and the issue seems to be fixed there by now.
Diffstat (limited to 'tests/unit/utils/test_utils.py')
-rw-r--r--tests/unit/utils/test_utils.py121
1 files changed, 0 insertions, 121 deletions
diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py
index c12a2f17c..3c00ca0c7 100644
--- a/tests/unit/utils/test_utils.py
+++ b/tests/unit/utils/test_utils.py
@@ -148,127 +148,6 @@ def test_resource_filename():
assert f.read().splitlines()[0] == "Hello World!"
-class Patcher:
-
- """Helper for TestActuteWarning.
-
- Attributes:
- monkeypatch: The pytest monkeypatch fixture.
- """
-
- def __init__(self, monkeypatch):
- self.monkeypatch = monkeypatch
-
- def patch_platform(self, platform='linux'):
- """Patch sys.platform."""
- self.monkeypatch.setattr(sys, 'platform', platform)
-
- def patch_exists(self, exists=True):
- """Patch os.path.exists."""
- self.monkeypatch.setattr(utils.os.path, 'exists', lambda path: exists)
-
- def patch_version(self, version='5.2.0'):
- """Patch Qt version."""
- self.monkeypatch.setattr(utils.qtutils, 'qVersion', lambda: version)
-
- def patch_file(self, data):
- """Patch open() to return the given data."""
- fake_file = io.StringIO(data)
- self.monkeypatch.setattr(utils, 'open',
- lambda filename, mode, encoding: fake_file,
- raising=False)
-
- def patch_all(self, data):
- """Patch everything so the issue would exist."""
- self.patch_platform()
- self.patch_exists()
- self.patch_version()
- self.patch_file(data)
-
-
-class TestActuteWarning:
-
- """Test actute_warning."""
-
- @pytest.fixture
- def patcher(self, monkeypatch):
- """Fixture providing a Patcher helper."""
- return Patcher(monkeypatch)
-
- def test_non_linux(self, patcher, capsys):
- """Test with a non-Linux OS."""
- patcher.patch_platform('toaster')
- utils.actute_warning()
- out, err = capsys.readouterr()
- assert not out
- assert not err
-
- def test_no_compose(self, patcher, capsys):
- """Test with no compose file."""
- patcher.patch_platform()
- patcher.patch_exists(False)
- utils.actute_warning()
- out, err = capsys.readouterr()
- assert not out
- assert not err
-
- def test_newer_qt(self, patcher, capsys):
- """Test with compose file but newer Qt version."""
- patcher.patch_platform()
- patcher.patch_exists()
- patcher.patch_version('5.4')
- utils.actute_warning()
- out, err = capsys.readouterr()
- assert not out
- assert not err
-
- def test_no_match(self, patcher, capsys):
- """Test with compose file and affected Qt but no match."""
- patcher.patch_all('foobar')
- utils.actute_warning()
- out, err = capsys.readouterr()
- assert not out
- assert not err
-
- def test_empty(self, patcher, capsys):
- """Test with empty compose file."""
- patcher.patch_all(None)
- utils.actute_warning()
- out, err = capsys.readouterr()
- assert not out
- assert not err
-
- def test_match(self, patcher, capsys):
- """Test with compose file and affected Qt and a match."""
- patcher.patch_all('foobar\n<dead_actute>\nbaz')
- utils.actute_warning()
- out, err = capsys.readouterr()
- assert out.startswith('Note: If you got a')
- assert not err
-
- def test_match_stdout_none(self, monkeypatch, patcher, capsys):
- """Test with a match and stdout being None."""
- patcher.patch_all('foobar\n<dead_actute>\nbaz')
- monkeypatch.setattr(sys, 'stdout', None)
- utils.actute_warning()
-
- def test_unreadable(self, mocker, patcher, capsys, caplog):
- """Test with an unreadable compose file."""
- patcher.patch_platform()
- patcher.patch_exists()
- patcher.patch_version()
- mocker.patch('qutebrowser.utils.utils.open', side_effect=OSError,
- create=True)
-
- with caplog.at_level(logging.ERROR, 'init'):
- utils.actute_warning()
-
- assert len(caplog.records) == 1
- assert caplog.records[0].message == 'Failed to read Compose file'
- out, _err = capsys.readouterr()
- assert not out
-
-
class TestInterpolateColor:
"""Tests for interpolate_color.