Ejemplo n.º 1
0
        def get_fixture(name):
            new_name = utils.un_camel_case(name)

            @pytest.fixture()
            def f(TestinfraBackend):
                # pylint: disable=protected-access
                return getattr(TestinfraBackend._host, new_name)
            f.__name__ = str(name)
            f.__doc__ = ('DEPRECATED: use host fixture and get {0} module '
                         'with host.{1}').format(name, new_name)
            return f
Ejemplo n.º 2
0
        def get_fixture(name):
            new_name = utils.un_camel_case(name)

            @pytest.fixture()
            def f(TestinfraBackend):
                # pylint: disable=protected-access
                return getattr(TestinfraBackend._host, new_name)
            f.__name__ = str(name)
            f.__doc__ = ('DEPRECATED: use host fixture and get {0} module '
                         'with host.{1}').format(name, new_name)
            return f
Ejemplo n.º 3
0
def pytest_collection_finish(session):
    deprecated_modules = set(m.title().replace("_", "")
                             for m in testinfra.modules.modules) | set(
                                 ['TestinfraBackend', 'LocalCommand'])
    deprecated_used = set()
    for item in session.items:
        deprecated_used |= (set(item.fixturenames) & deprecated_modules)
    for name in sorted(deprecated_used):
        if name == 'LocalCommand':
            msg = ("LocalCommand fixture is deprecated. Use host fixture "
                   "and get LocalCommand with host.get_host('local://')")
        elif name == 'TestinfraBackend':
            msg = ("TestinfraBackend fixture is deprecated. Use host fixture "
                   "and get backend with host.backend")
        elif name == 'Command':
            msg = "Command fixture is deprecated. Use host fixture instead"
        else:
            msg = ("{0} fixture is deprecated. Use host fixture and get "
                   "{0} module with host.{1}").format(
                       name, utils.un_camel_case(name))
        session.config.warn('C1', msg)
Ejemplo n.º 4
0
def pytest_collection_finish(session):
    deprecated_modules = set(
        m.title().replace("_", "") for m in testinfra.modules.modules) | set(
            ['TestinfraBackend', 'LocalCommand'])
    deprecated_used = set()
    for item in session.items:
        if hasattr(item, 'fixturenames'):
            # DoctestItem does not have fixturenames attribute
            deprecated_used |= (set(item.fixturenames) & deprecated_modules)
    for name in sorted(deprecated_used):
        if name == 'LocalCommand':
            msg = ("LocalCommand fixture is deprecated. Use host fixture "
                   "and get LocalCommand with host.get_host('local://')")
        elif name == 'TestinfraBackend':
            msg = ("TestinfraBackend fixture is deprecated. Use host fixture "
                   "and get backend with host.backend")
        elif name == 'Command':
            msg = "Command fixture is deprecated. Use host fixture instead"
        else:
            msg = (
                "{0} fixture is deprecated. Use host fixture and get "
                "{0} module with host.{1}"
            ).format(name, utils.un_camel_case(name))
        session.config.warn('C1', msg)