summaryrefslogtreecommitdiff
path: root/tests/unit/extensions/test_loader.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-12-10 12:15:10 +0100
committerFlorian Bruhin <me@the-compiler.org>2018-12-10 12:37:58 +0100
commitec5a93a80dea06fed31f8779c837800658f8bb59 (patch)
tree4417000e622c80f8a0ffe9c4c5d90b7f871c4db0 /tests/unit/extensions/test_loader.py
parent38c4ef3623fd271aaa6708852af577d819cd1803 (diff)
downloadqutebrowser-ec5a93a80dea06fed31f8779c837800658f8bb59.tar.gz
qutebrowser-ec5a93a80dea06fed31f8779c837800658f8bb59.zip
Add tests for extensions.loader
Diffstat (limited to 'tests/unit/extensions/test_loader.py')
-rw-r--r--tests/unit/extensions/test_loader.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/unit/extensions/test_loader.py b/tests/unit/extensions/test_loader.py
new file mode 100644
index 000000000..e0c1912fa
--- /dev/null
+++ b/tests/unit/extensions/test_loader.py
@@ -0,0 +1,49 @@
+# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
+
+# Copyright 2018 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/>.
+
+import pytest
+
+from qutebrowser.extensions import loader
+from qutebrowser.misc import objects
+
+
+def test_on_walk_error():
+ with pytest.raises(ImportError, match='Failed to import foo'):
+ loader._on_walk_error('foo')
+
+
+def test_walk_normal():
+ names = [info.name for info in loader._walk_normal()]
+ assert 'qutebrowser.components.scrollcommands' in names
+
+
+def test_walk_pyinstaller():
+ # We can't test whether we get something back without being frozen by
+ # PyInstaller, but at least we can test that we don't crash.
+ list(loader._walk_pyinstaller())
+
+
+def test_load_component(monkeypatch):
+ monkeypatch.setattr(objects, 'commands', {})
+
+ info = loader.ExtensionInfo(name='qutebrowser.components.scrollcommands')
+ module = loader._load_component(info)
+
+ assert hasattr(module, 'scroll_to_perc')
+ assert 'scroll-to-perc' in objects.commands