コード例 #1
0
ファイル: test_decorators.py プロジェクト: tuxxon/gitfs
    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")
コード例 #2
0
ファイル: test_decorators.py プロジェクト: HWL-RobAt/gitfs
    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")
コード例 #3
0
ファイル: test_decorators.py プロジェクト: wlchou/gitfs
    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)