Skip to content

AustinScola/pytest-motor

Repository files navigation

pytest-motor

PyPI version PyPI status codecov https://github.com/AustinScola/pytest-motor/actions/workflows/python.yaml PyPI pyversions Code style

A pytest plugin for Motor, the non-blocking MongoDB driver.

Installation

To install pytest-motor, run:

pip install pytest-motor

Example

from motor.motor_asyncio import AsyncIOMotorClient
import pytest


@pytest.mark.asyncio
async def test_using_motor_client(motor_client: AsyncIOMotorClient) -> None:
    """This test has access to a Motor client."""
    await motor_client.server_info()

How it works

When a test session runs, pytest-motor checks that the mongod binary is present in the .mongod subdirectory of the pytest root path. If it is not preset, it will be downloaded. This means that the first run make take some time. Subsequent runs will be faster.

Each test function uses a new motor_client and database. (This may change in the future.)

Limitations

pytest-motor currently supports:

  • Ubuntu 16.04*, 18.04, and 20.04
  • Debian 9.2* and 10.0*
  • MacOS
  • Windows

*NOT tested.

If you would like support for another system, please make a GitHub Issue. Contributions are welcome!

About

A pytest plugin for motor, the non-blocking MongoDB driver.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors