It was my initial thought but I failed to set up the test within a reasonable time.
Iv'e managed to increase the coverage by your instructions, thank you.
> your test 'test_on_lock_button_toggled_search_tab' is only really testing the
> last two lines of on_lock_button_toggled
>
> As, you've gone to all the trouble of setting this test up it would be easy to
> test the if condition which sets the appropriate icon. In your current test
> add:
>
> # GIVEN:
> self.media_item.lock_icon = 'lock icon'
> sender_instance_mock = MagicMock()
> self.media_item.sender = MagicMock(return_value=sender_instance_mock)
>
> # THEN:
> sender_instance_mock.setIcon.assert_called_once_with('lock icon')
>
> Then you can just copy and paste your test, make a few modifications calling
> self.media_item.on_lock_button_toggled with False and you've provided 100%
> coverage for the on_lock_button_toggled method, for not too much extra effort.
>
> See also my inline comment for one small issue with your current test.
It was my initial thought but I failed to set up the test within a reasonable time.
Iv'e managed to increase the coverage by your instructions, thank you.
> your test 'test_on_ lock_button_ toggled_ search_ tab' is only really testing the button_ toggled item.lock_ icon = 'lock icon' instance_ mock = MagicMock() item.sender = MagicMock( return_ value=sender_ instance_ mock) instance_ mock.setIcon. assert_ called_ once_with( 'lock icon') item.on_ lock_button_ toggled with False and you've provided 100% button_ toggled method, for not too much extra effort.
> last two lines of on_lock_
>
> As, you've gone to all the trouble of setting this test up it would be easy to
> test the if condition which sets the appropriate icon. In your current test
> add:
>
> # GIVEN:
> self.media_
> sender_
> self.media_
>
> # THEN:
> sender_
>
> Then you can just copy and paste your test, make a few modifications calling
> self.media_
> coverage for the on_lock_
>
> See also my inline comment for one small issue with your current test.