aio-libs / aiobotocore

asyncio support for botocore library using aiohttp
https://aiobotocore.rtfd.io
Apache License 2.0
1.12k stars 179 forks source link

Feature request - package pytest fixtures for downstream libs #753

Open dazza-codes opened 4 years ago

dazza-codes commented 4 years ago

Would it be possible to add a development option to the package so that it can provide pytest fixtures to downstream projects? Something like aiobotocore[dev] might provide pytest fixture methods? (It might introduce additional namespace requirements on the test suite.)

For example, dask provides test utilities in the package, see

Maybe this is out-of-scope in this project or it means a spin-off for something like a new "aiomoto" project.

PS, this is not a bug report - the issue creation options did not include a "feature request"

Related issues: #583 and #665

thehesiod commented 4 years ago

what in particular pytest packages would you like aioboto to provide? Seems like this is more of a aiomoto kind of thing.

dazza-codes commented 4 years ago

In the short term, it might help if this project could expose a package-extra that might somehow bundle the pytest fixtures that manage the moto server (the tests/conftest.py module and the associated moto_server.py). Using moto defaults, it hooks into the before-call event and short-circuits all the aiobotocore request/response processing, but the test suite in this project disables that default moto behavior (details are noted in #755). Another option is to figure out a PR on moto that might provide some kind of aio option for the moto.settings.

# setup.py
setup(
    # the following makes a plugin available to pytest
    entry_points = {
        'pytest11': [
            'aiomoto = tests.conftest.py',  # or something
        ]
    },
    classifiers=["Framework :: Pytest"],
)

Providing the pytest-fixtures as a package extra would allow the fixtures to remain in this project so they continue to evolve along with this project, to be sure they work as required. If they are split out into a new aiomoto project, it could take on an independent life unless this project starts to depend on it as a pytest plugin. In the long term, an aiomoto project might replace flask with sanic for the server (but that might not really help things a whole lot).