Add some tests for -OO logging

This commit is contained in:
Florian Bruhin 2016-08-10 09:05:04 +02:00
parent 26af2b3089
commit f0133624bf
2 changed files with 35 additions and 0 deletions

View File

@ -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()

View File

@ -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: