Testing module reference

Contains various test-related utilities.

See tests/ for examples of testing Micro.Web application

class micro.web.testing.AppTestCase(methodName='runTest')[source]

A test case for application which is capable of creating application test servers.

make_request(method, url, *args, **kwargs)[source]

Make a request to a previously run application

Parameters:
  • method (str) – HTTP method to use for request
  • url – A relative URL to be requested
  • args – Arguments to be proxied to aiohttp.client.request
  • kwargs – Keyworded arguments to be proxied to aiohttp.client.request
Returns:

Waiter for response

Return type:

asyncio.Task

run_app(app)[source]

Run the application for testing. Be aware to call yield from stop_server() when the test succeeds

Parameters:app (micro.web.Micro) – Application instance to run
stop_server()[source]

Stop the running server, which has been previously started with run_app()

micro.web.testing.task_succeed(result)[source]

Inspired by t.i.defer.succeed, wraps a value in coroutine which returns that value. Suitable for providing return values for coroutine mocks.