pytest.Class

Here are the examples of the python api pytest.Class taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

Example 1

Project: pytest Source File: fixtures.py
Function: pytest_namespace
def pytest_namespace():
    scopename2class.update({
        'class': pytest.Class,
        'module': pytest.Module,
        'function': pytest.Item,
    })
    return {
        'fixture': fixture,
        'yield_fixture': yield_fixture,
        'collect': {'_fillfuncargs': fillfixtures}
    }

Example 2

Project: pytest Source File: fixtures.py
Function: cls
    @scopeproperty("class")
    def cls(self):
        """ class (can be None) where the test function was collected. """
        clscol = self._pyfuncitem.getparent(pytest.Class)
        if clscol:
            return clscol.obj

Example 3

Project: SickGear Source File: pytestplugin.py
Function: pytest_pycollect_makeitem
def pytest_pycollect_makeitem(collector, name, obj):

    if inspect.isclass(obj) and plugin_base.want_class(obj):
        return pytest.Class(name, parent=collector)
    elif inspect.isfunction(obj) and \
            name.startswith("test_") and \
            isinstance(collector, pytest.Instance):
        return pytest.Function(name, parent=collector)
    else:
        return []

Example 4

Project: alembic Source File: pytestplugin.py
def pytest_pycollect_makeitem(collector, name, obj):
    if inspect.isclass(obj) and plugin_base.want_class(obj):
        return pytest.Class(name, parent=collector)
    elif inspect.isfunction(obj) and \
            isinstance(collector, pytest.Instance) and \
            plugin_base.want_method(collector.cls, obj):
        return pytest.Function(name, parent=collector)
    else:
        return []

Example 5

Project: pyp2rpm Source File: python.py
Function: cls
    @property
    def cls(self):
        """ class (can be None) where the test function was collected. """
        clscol = self._pyfuncitem.getparent(pytest.Class)
        if clscol:
            return clscol.obj

Example 6

Project: pyp2rpm Source File: python.py
    def _getscopeitem(self, scope):
        if scope == "function":
            return self._pyfuncitem
        elif scope == "session":
            return None
        elif scope == "class":
            x = self._pyfuncitem.getparent(pytest.Class)
            if x is not None:
                return x
            scope = "module"
        if scope == "module":
            return self._pyfuncitem.getparent(pytest.Module)
        raise ValueError("unknown finalization scope %r" %(scope,))