from .fixtures import *  # noqa


def pytest_addoption(parser):
    group = parser.getgroup('girder')
    group.addoption('--mock-db', action='store_true', default=False,
                    help='Whether or not to mock the database using mongomock.')
    group.addoption('--mongo-uri', action='store', default='mongodb://localhost:27017',
                    help=('The base URI to the MongoDB instance to use for database connections, '
                          'default is mongodb://localhost:27017'))
    group.addoption('--drop-db', action='store', default='both',
                    choices=('both', 'pre', 'post', 'never'),
                    help='When to destroy testing databases, default is both '
                    '(before and after running tests)')

import os
from .fixtures import *  # noqa


def pytest_configure(config):
    """
    Create the necessary directories for coverage. This is necessary because neither coverage nor
    pytest-cov have support for making the data_file directory before running.
    """
    covPlugin = config.pluginmanager.get_plugin('_cov')

    if covPlugin is not None:
        covPluginConfig = covPlugin.cov_controller.cov.config
        covDataFileDir = os.path.dirname(covPluginConfig.data_file)

        try:
            os.makedirs(covDataFileDir)
        except OSError:
            pass


def pytest_addoption(parser):
    group = parser.getgroup('girder')
    group.addoption('--mock-db', action='store_true', default=False,
                    help='Whether or not to mock the database using mongomock.')
    group.addoption('--mongo-uri', action='store', default='mongodb://localhost:27017',
                    help=('The base URI to the MongoDB instance to use for database connections, '
                          'default is mongodb://localhost:27017'))
    group.addoption('--drop-db', action='store', default='both',
                    choices=('both', 'pre', 'post', 'never'),
                    help='When to destroy testing databases, default is both '
                    '(before and after running tests)')

Add a pytest hook for creating the coverage data_file directory
Add a pytest hook for creating the coverage data_file directory

+ import os
  from .fixtures import *  # noqa
+ 
+ 
+ def pytest_configure(config):
+     """
+     Create the necessary directories for coverage. This is necessary because neither coverage nor
+     pytest-cov have support for making the data_file directory before running.
+     """
+     covPlugin = config.pluginmanager.get_plugin('_cov')
+ 
+     if covPlugin is not None:
+         covPluginConfig = covPlugin.cov_controller.cov.config
+         covDataFileDir = os.path.dirname(covPluginConfig.data_file)
+ 
+         try:
+             os.makedirs(covDataFileDir)
+         except OSError:
+             pass
  
  
  def pytest_addoption(parser):
      group = parser.getgroup('girder')
      group.addoption('--mock-db', action='store_true', default=False,
                      help='Whether or not to mock the database using mongomock.')
      group.addoption('--mongo-uri', action='store', default='mongodb://localhost:27017',
                      help=('The base URI to the MongoDB instance to use for database connections, '
                            'default is mongodb://localhost:27017'))
      group.addoption('--drop-db', action='store', default='both',
                      choices=('both', 'pre', 'post', 'never'),
                      help='When to destroy testing databases, default is both '
                      '(before and after running tests)')
  
Add a pytest hook for creating the coverage data_file directory
## Code Before:
from .fixtures import *  # noqa


def pytest_addoption(parser):
    group = parser.getgroup('girder')
    group.addoption('--mock-db', action='store_true', default=False,
                    help='Whether or not to mock the database using mongomock.')
    group.addoption('--mongo-uri', action='store', default='mongodb://localhost:27017',
                    help=('The base URI to the MongoDB instance to use for database connections, '
                          'default is mongodb://localhost:27017'))
    group.addoption('--drop-db', action='store', default='both',
                    choices=('both', 'pre', 'post', 'never'),
                    help='When to destroy testing databases, default is both '
                    '(before and after running tests)')

## Instruction:
Add a pytest hook for creating the coverage data_file directory
## Code After:
import os
from .fixtures import *  # noqa


def pytest_configure(config):
    """
    Create the necessary directories for coverage. This is necessary because neither coverage nor
    pytest-cov have support for making the data_file directory before running.
    """
    covPlugin = config.pluginmanager.get_plugin('_cov')

    if covPlugin is not None:
        covPluginConfig = covPlugin.cov_controller.cov.config
        covDataFileDir = os.path.dirname(covPluginConfig.data_file)

        try:
            os.makedirs(covDataFileDir)
        except OSError:
            pass


def pytest_addoption(parser):
    group = parser.getgroup('girder')
    group.addoption('--mock-db', action='store_true', default=False,
                    help='Whether or not to mock the database using mongomock.')
    group.addoption('--mongo-uri', action='store', default='mongodb://localhost:27017',
                    help=('The base URI to the MongoDB instance to use for database connections, '
                          'default is mongodb://localhost:27017'))
    group.addoption('--drop-db', action='store', default='both',
                    choices=('both', 'pre', 'post', 'never'),
                    help='When to destroy testing databases, default is both '
                    '(before and after running tests)')
