Stabilize :session-save --quiet test
By adding a way to check for the loglevel, we can easily check there's no message but still wait for the session to be saved.
This commit is contained in:
parent
f34bdfbb50
commit
7a3554e77a
@ -519,7 +519,9 @@ class SessionManager(QObject):
|
|||||||
raise cmdexc.CommandError("Error while saving session: {}"
|
raise cmdexc.CommandError("Error while saving session: {}"
|
||||||
.format(e))
|
.format(e))
|
||||||
else:
|
else:
|
||||||
if not quiet:
|
if quiet:
|
||||||
|
log.sessions.debug("Saved session {}.".format(name))
|
||||||
|
else:
|
||||||
message.info("Saved session {}.".format(name))
|
message.info("Saved session {}.".format(name))
|
||||||
|
|
||||||
@cmdutils.register(instance='session-manager')
|
@cmdutils.register(instance='session-manager')
|
||||||
|
@ -439,14 +439,21 @@ def expect_message(quteproc, server, category, message):
|
|||||||
|
|
||||||
|
|
||||||
@bdd.then(bdd.parsers.re(r'(?P<is_regex>regex )?"(?P<pattern>[^"]+)" should '
|
@bdd.then(bdd.parsers.re(r'(?P<is_regex>regex )?"(?P<pattern>[^"]+)" should '
|
||||||
r'be logged'))
|
r'be logged( with level (?P<loglevel>.*))?'))
|
||||||
def should_be_logged(quteproc, server, is_regex, pattern):
|
def should_be_logged(quteproc, server, is_regex, pattern, loglevel):
|
||||||
"""Expect the given pattern on regex in the log."""
|
"""Expect the given pattern on regex in the log."""
|
||||||
if is_regex:
|
if is_regex:
|
||||||
pattern = re.compile(pattern)
|
pattern = re.compile(pattern)
|
||||||
else:
|
else:
|
||||||
pattern = pattern.replace('(port)', str(server.port))
|
pattern = pattern.replace('(port)', str(server.port))
|
||||||
line = quteproc.wait_for(message=pattern)
|
|
||||||
|
args = {
|
||||||
|
'message': pattern,
|
||||||
|
}
|
||||||
|
if loglevel:
|
||||||
|
args['loglevel'] = getattr(logging, loglevel.upper())
|
||||||
|
|
||||||
|
line = quteproc.wait_for(**args)
|
||||||
line.expected = True
|
line.expected = True
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ Feature: Saving and loading sessions
|
|||||||
|
|
||||||
Scenario: Saving session with --quiet
|
Scenario: Saving session with --quiet
|
||||||
When I run :session-save --quiet quiet_session
|
When I run :session-save --quiet quiet_session
|
||||||
Then "Saved session quiet_session." should not be logged
|
Then "Saved session quiet_session." should be logged with level debug
|
||||||
And the session quiet_session should exist
|
And the session quiet_session should exist
|
||||||
|
|
||||||
Scenario: Saving session with --only-active-window
|
Scenario: Saving session with --only-active-window
|
||||||
|
Loading…
Reference in New Issue
Block a user