Minor style fixes

This commit is contained in:
Eskil Heyn Olsen
2013-01-06 14:40:09 -08:00
parent 075ccf6a82
commit 675b29b4fe
2 changed files with 10 additions and 5 deletions
+9 -4
View File
@@ -316,14 +316,15 @@ def capture_reset_password_requests(reset_password_sent_at=None):
class CaptureSignals(object):
""" Testing utility for capturing blinker signals.
"""Testing utility for capturing blinker signals.
Context manager which mocks out selected signals and registers which are `sent` on and what
arguments were sent. Instantiate with a list of blinker `NamedSignals` to patch. Each signal
has it's `send` mocked out.
"""
def __init__(self, signals):
""" Patch all given signals and make them available as attributes.
"""Patch all given signals and make them available as attributes.
:param signals: list of signals
"""
self._records = {}
@@ -333,7 +334,8 @@ class CaptureSignals(object):
self._receivers[signal] = functools.partial(self._record, signal)
def __getitem__(self, signal):
""" All captured signals are available via `ctxt[signal]`."""
"""All captured signals are available via `ctxt[signal]`.
"""
if isinstance(signal, blinker.base.NamedSignal):
return self._records[signal]
else:
@@ -352,11 +354,14 @@ class CaptureSignals(object):
signal.disconnect(receiver)
def signals_sent(self):
"""Return a set of the signals sent.
:rtype: list of blinker `NamedSignals`.
"""
return set([signal for signal, _ in self._records.iteritems() if self._records[signal]])
def capture_signals():
""" Factory method that creates a `CaptureSignals` with all the flask_security signals."""
"""Factory method that creates a `CaptureSignals` with all the flask_security signals."""
return CaptureSignals([user_registered, user_confirmed,
confirm_instructions_sent, login_instructions_sent,
password_reset, reset_password_instructions_sent])
+1 -1
View File
@@ -10,7 +10,7 @@ from tests import SecurityTest
def compare_user(a, b):
""" Helper to compare two users."""
"""Helper to compare two users."""
return a.id == b.id and a.email == b.email and a.password == b.password