Each MongoDB process fixture can be configured in a different way than the others through the fixture factory arguments.

Configuration

You can define your settings in three ways, it’s fixture factory argument, command line option and pytest.ini configuration option.
You can pick which you prefer, but remember that these settings are handled in the following order:

Fixture factory argument

Command line option

Configuration option in your pytest.ini file

What

Fixture factory argument

Command line option

pytest.ini option

Default

Path to mongodb exec

executable

–mongo-exec

mongo_exec

/usr/bin/mongod

MongoDB host

host

–mongo-host

mongo_host

127.0.0.1

MongoDB port

port

–mongo-port

mongo_port

random

Path to store logs

logsdir

–mongo-logsdir

mongo_logsdir

$TMPDIR

Additional parameters

params

–mongo-params

mongo_params

Example usage:

pass it as an argument in your own fixture

mongo_proc=factories.mongo_proc(port=8888)

use --mongo-port command line option when you run your tests

py.test tests --mongo-port=8888

specify your directory as mongo_port in your pytest.ini file.

To do so, put a line like the following under the [pytest] section of your pytest.ini: