Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
145 lines (66 sloc) 2.77 KB

Examples

Basic mocking example using requests

.. literalinclude:: ../examples/requests_client.py



Chainable API DSL

.. literalinclude:: ../examples/chainable_api.py



Context manager for isolated mocking

.. literalinclude:: ../examples/context_manager.py


Single mock context manager definition for isolated mocking

.. literalinclude:: ../examples/mock_context_manager.py


Declaring mocks as decorators

.. literalinclude:: ../examples/decorators.py


Activating the mock engine via decorator within the function context

.. literalinclude:: ../examples/decorator_activate.py


Activating the mock engine via decorator within an async coroutine function context

.. literalinclude:: ../examples/decorator_activate_async.py


Featured JSON body matching

.. literalinclude:: ../examples/json_matching.py



JSONSchema based body matching

.. literalinclude:: ../examples/json_schema.py



Enable real networking mode

.. literalinclude:: ../examples/network_mode.py



Persistent mock

.. literalinclude:: ../examples/persistent_mock.py



Time TTL limited mock

.. literalinclude:: ../examples/time_ttl_mock.py



Regular expression matching

.. literalinclude:: ../examples/regex.py



unittest integration

.. literalinclude:: ../examples/unittest_example.py



py.test integration

.. literalinclude:: ../examples/pytest_example.py



Simulated error exception on mock matching

.. literalinclude:: ../examples/simulated_error.py



Using urllib3 as HTTP client

.. literalinclude:: ../examples/urllib3_client.py



Asynchronous HTTP request using aiohttp

.. literalinclude:: ../examples/aiohttp_client.py



Using http.client standard Python package as HTTP client

.. literalinclude:: ../examples/http_client_native.py


Example using mocket Python library as underlying mock engine

.. literalinclude:: ../examples/mocket_example.py


Hy programming language example

.. literalinclude:: ../examples/basic.hy


You can’t perform that action at this time.