Skip to content

Commit

Permalink
Fix branch coverage for un-called callbacks. (#6242)
Browse files Browse the repository at this point in the history
Use 'mock.Mock()' w/ 'return_value' True, rather than inlining
'lambda _: True' in cases where the callback doesn't get called.
  • Loading branch information
tseaver authored Oct 17, 2018
1 parent f0449e0 commit 7527a4e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api_core/tests/unit/test_bidi.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ def cancel(self):

class TestResumableBidiRpc(object):
def test_initial_state(self):
bidi_rpc = bidi.ResumableBidiRpc(None, lambda _: True)
callback = mock.Mock()
callback.return_value = True
bidi_rpc = bidi.ResumableBidiRpc(None, callback)

assert bidi_rpc.is_active is False

Expand Down Expand Up @@ -380,7 +382,9 @@ def test_recv_recover_already_recovered(self):
grpc.StreamStreamMultiCallable,
instance=True,
side_effect=[call_1, call_2])
bidi_rpc = bidi.ResumableBidiRpc(start_rpc, lambda _: True)
callback = mock.Mock()
callback.return_value = True
bidi_rpc = bidi.ResumableBidiRpc(start_rpc, callback)

bidi_rpc.open()

Expand Down

0 comments on commit 7527a4e

Please sign in to comment.