pytest_dbfixtures.factories

Groups factories to be importable from one place.

Redis factories

pytest_dbfixtures.factories.redis.redis_proc(executable=None, params=None, config_file=None, host=None, port=None, logs_prefix='')[source]

Redis process factory.

Parameters:
  • executable (str) – path to redis-server
  • params (str) – params
  • config_file (str) – path to config file
  • host (str) – hostname
  • port (str) –

    exact port (e.g. ‘8000’) or randomly selected port:

    ‘?’ - any random available port ‘2000-3000’ - random available port from a given range ‘4002,4003’ - random of 4002 or 4003 ports
  • logs_prefix (str) – prefix for log filename
Return type:

func

Returns:

function which makes a redis process

pytest_dbfixtures.factories.redis.redisdb(process_fixture_name, db=None, strict=True)[source]

Redis database factory.

Parameters:
  • process_fixture_name (str) – name of the process fixture
  • db (int) – number of database
  • strict (bool) – if true, uses StrictRedis client class
Return type:

func

Returns:

function which makes a connection to redis

Mongo factories

pytest_dbfixtures.factories.mongo.mongo_proc(executable=None, params=None, host=None, port=None, logs_prefix='')[source]

Mongo process factory.

Parameters:
  • executable (str) – path to mongod
  • params (str) – params
  • host (str) – hostname
  • port (str) –

    exact port (e.g. ‘8000’) or randomly selected port:

    ‘?’ - any random available port ‘2000-3000’ - random available port from a given range ‘4002,4003’ - random of 4002 or 4003 ports
  • logs_prefix (str) – prefix for log filename
Return type:

func

Returns:

function which makes a mongo process

pytest_dbfixtures.factories.mongo.mongodb(process_fixture_name)[source]

Mongo database factory.

Parameters:process_fixture_name (str) – name of the process fixture
Return type:func
Returns:function which makes a connection to mongo

Postgresql factories

pytest_dbfixtures.factories.postgresql.postgresql(process_fixture_name, db=None)[source]

postgresql database factory.

Parameters:
  • process_fixture_name (str) – name of the process fixture
  • db (int) – database name
Return type:

func

Returns:

function which makes a connection to postgresql

pytest_dbfixtures.factories.postgresql.postgresql_proc(executable=None, host=None, port=None, logs_prefix='')[source]

postgresql process factory.

Parameters:
  • executable (str) – path to postgresql_ctl
  • host (str) – hostname
  • port (str) –

    exact port (e.g. ‘8000’) or randomly selected port:

    ‘?’ - any random available port ‘2000-3000’ - random available port from a given range ‘4002,4003’ - random of 4002 or 4003 ports
  • logs_prefix (str) – prefix for log filename
Return type:

func

Returns:

function which makes a postgresql process

Mysql factories

pytest_dbfixtures.factories.mysql.mysql_proc(executable=None, admin_executable=None, init_executable=None, host=None, port=None, params=None, logs_prefix='')[source]

Mysql server process factory.

Parameters:
  • executable (str) – path to mysql executable
  • admin_executable (str) – path to mysql_admin executable
  • init_executable (str) – path to mysql_init executable
  • host (str) – hostname
  • port (str) –

    exact port (e.g. ‘8000’) or randomly selected port:

    ‘?’ - any random available port ‘2000-3000’ - random available port from a given range ‘4002,4003’ - random of 4002 or 4003 ports
  • params (str) – additional command-line mysqld parameters
  • logs_prefix (str) – prefix for log filename
Return type:

func

Returns:

function which makes a redis process

Elasticsearch factories

pytest_dbfixtures.factories.elasticsearch.elasticsearch_proc(host='127.0.0.1', port=9201, cluster_name=None, network_publish_host='127.0.0.1', discovery_zen_ping_multicast_enabled=False, index_store_type='memory', logs_prefix='')[source]

Creates elasticsearch process fixture.

Warning

This fixture requires at least version 1.0 of elasticsearch to work.

Parameters:
pytest_dbfixtures.factories.elasticsearch.elasticsearch(process_fixture_name)[source]

Creates Elasticsearch client fixture.

Parameters:process_fixture_name (str) – elasticsearch process fixture name