Util Asynctestcase

Adds support for test cases which need to be run in an event loop.

Also contains a class integration tests can derive from. The integration tests can declare which of the plugins (that are a part of the main repo) they require to run. The test will be skipped if the plugin isn’t installed in development mode.

To install all plugins in development mode $ dffml service dev install

Add the -user flag to install to ~/.local

class dffml.util.asynctestcase.AsyncTestCase(methodName='runTest')[source]

Runs any test_ methods as coroutines in the default event loop.

Examples

>>> import asyncio
>>> from dffml import AsyncTestCase
>>>
>>> class AsyncTestCase(AsyncTestCase):
...     async def test_sleep(self):
...         await asyncio.sleep(1)
async_wrapper(coro)[source]

Returns a function which calls the test_ function which calls loop.run_until_complete to return the result of the test.

run(result=None)[source]

Convert all test_ methods via async_wrapper so that they are run in the event loop.

async setUp()[source]

Hook method for setting up the test fixture before exercising it.

async tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

dffml.util.asynctestcase.non_existant_tempfile()[source]

Yield the filename of a non-existant file within a temporary directory

dffml.util.asynctestcase.relative_chdir(*args)[source]

Change directory to a location relative to the location of this file.

dffml.util.asynctestcase.relative_path(*args)[source]

Returns a pathlib.Path object with the path relative to this file.