Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_relogin(self):
recorder = betamax.Betamax(self.session)
with recorder.use_cassette('relogin'):
with mock.patch.multiple(
'somecomfort.SomeComfort',
_login=mock.DEFAULT,
_discover=mock.DEFAULT,
keepalive=mock.DEFAULT) as (l, d, k):
SomeComfort.keepalive.side_effect = somecomfort.SessionTimedOut
c = SomeComfort(self.username, self.password)
c._login.assert_called_once_with()
with mock.patch.object(c, 'keepalive') as mock_k:
tries = [1]
def fake_keepalive():
if tries:
tries.pop()
raise somecomfort.SessionTimedOut()
mock_k.side_effect = fake_keepalive
c._discover()