diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py index d34859410..840465704 100644 --- a/tests/end2end/test_invocations.py +++ b/tests/end2end/test_invocations.py @@ -110,3 +110,16 @@ def test_no_loglines(quteproc_new): quteproc_new.start(args=['--temp-basedir', '--loglines=0'] + BASE_ARGS) quteproc_new.open_path('qute:log') assert quteproc_new.get_content() == 'Log output was disabled.' + + +@pytest.mark.parametrize('level', ['1', '2']) +def test_optimize(quteproc_new, capfd, level): + quteproc_new.start(args=['--temp-basedir'] + BASE_ARGS, + env={'PYTHONOPTIMIZE': level}) + if level == '2': + msg = ("Running on optimize level higher than 1, unexpected behavior " + "may occur.") + line = quteproc_new.wait_for(message=msg) + line.expected = True + quteproc_new.send_cmd(':quit') + quteproc_new.wait_for_quit() diff --git a/tests/unit/commands/test_cmdutils.py b/tests/unit/commands/test_cmdutils.py index 1ecdbaf3a..cd074cbcd 100644 --- a/tests/unit/commands/test_cmdutils.py +++ b/tests/unit/commands/test_cmdutils.py @@ -21,6 +21,10 @@ """Tests for qutebrowser.commands.cmdutils.""" +import sys +import logging +import types + import pytest from qutebrowser.commands import cmdutils, cmdexc, argparser, command @@ -354,6 +358,24 @@ class TestArgument: assert str(excinfo.value) == "Argument marked as both count/win_id!" + def test_no_docstring(self, caplog): + with caplog.at_level(logging.WARNING): + @cmdutils.register() + def fun(): + # no docstring + pass + assert len(caplog.records) == 1 + msg = caplog.records[0].message + assert msg.endswith('test_cmdutils.py has no docstring') + + def test_no_docstring_with_optimize(self, monkeypatch): + """With -OO we'd get a warning on start, but no warning afterwards.""" + monkeypatch.setattr(sys, 'flags', types.SimpleNamespace(optimize=2)) + @cmdutils.register() + def fun(): + # no docstring + pass + class TestRun: