Exemple #1
0
    def test_while_not_with_invalid_event_type(self):
        mocked_method = MagicMock()
        mocked_self = EmptyMock(obj="obj")

        with patch.multiple("gitfs.utils.decorators.while_not", wraps=MockedWraps):
            with pytest.raises(TypeError):
                not_now = while_not("obj")
                not_now(mocked_method)(mocked_self, "arg", kwarg="kwarg")
Exemple #2
0
    def test_while_not_with_invalid_event_type(self):
        mocked_method = MagicMock()
        mocked_self = EmptyMock(obj="obj")

        with patch.multiple('gitfs.utils.decorators.while_not',
                            wraps=MockedWraps):
            with pytest.raises(TypeError):
                not_now = while_not("obj")
                not_now(mocked_method)(mocked_self, "arg", kwarg="kwarg")
Exemple #3
0
    def test_while_not(self):
        an_event = Event()
        an_event.set()

        mocked_method = MagicMock()
        mocked_time = MagicMock()

        mocked_time.sleep.side_effect = lambda x: an_event.clear()
        mocked_method.__name__ = "name"

        with patch.multiple('gitfs.utils.decorators.while_not',
                            wraps=MockedWraps, time=mocked_time):
            not_now = while_not(an_event)
            not_now(mocked_method)("arg", kwarg="kwarg")

            mocked_time.sleep.assert_called_once_with(0.2)