pook/engine.py
def set_mock_engine(self, engine):
        """
        Sets a custom mock engine, replacing the built-in one.

        This is particularly useful if you want to replace the built-in
        HTTP traffic mock interceptor engine with your custom one.

        For mock engine implementation details, see `pook.MockEngine`.

        Arguments:
            engine (pook.MockEngine): custom mock engine to use.
        """
        if not engine:
            raise TypeError('engine must be a valid object')

        # Instantiate mock engine
        mock_engine = engine(self)

        # Validate minimum viable interface
        methods = ('activate', 'disable')
        if not all([hasattr(mock_engine, method) for method in methods]):
            raise NotImplementedError('engine must implementent the '
                                      'required methods')

        # Use the custom mock engine
        self.mock_engine = mock_engine

        # Enable mock engine, if needed
        if self.active:
            self.mock_engine.activate()
def set_mock_engine(self, engine):
        if not engine:
            raise TypeError('engine must be a valid object')

        # Instantiate mock engine
        mock_engine = engine(self)

        # Validate minimum viable interface
        methods = ('activate', 'disable')
        if not all([hasattr(mock_engine, method) for method in methods]):
            raise NotImplementedError('engine must implementent the '
                                      'required methods')

        # Use the custom mock engine
        self.mock_engine = mock_engine

        # Enable mock engine, if needed
        if self.active:
            self.mock_engine.activate()
def set_mock_engine ( self , engine ) : if not engine : raise TypeError ( 'engine must be a valid object' ) # Instantiate mock engine mock_engine = engine ( self ) # Validate minimum viable interface methods = ( 'activate' , 'disable' ) if not all ( [ hasattr ( mock_engine , method ) for method in methods ] ) : raise NotImplementedError ( 'engine must implementent the ' 'required methods' ) # Use the custom mock engine self . mock_engine = mock_engine # Enable mock engine, if needed if self . active : self . mock_engine . activate ( )
Sets a custom mock engine, replacing the built-in one.

        This is particularly useful if you want to replace the built-in
        HTTP traffic mock interceptor engine with your custom one.

        For mock engine implementation details, see `pook.MockEngine`.

        Arguments:
            engine (pook.MockEngine): custom mock engine to use.
Sets a custom mock engine replacing the built - in one .