예제 #1
0
def pytest_pycollect_makeitem(collector, name, obj):
    """pytest hook that adds docstring metadata (if found) to a test's meta mark"""
    if not isinstance(obj, FunctionType):
        return

    # __doc__ can be empty or nonexistent, make sure it's an empty string in that case
    metadata = get_meta(obj)
    # this is just bad - apply the marks better once we go pytest 3.6+
    # ideally we would check a FunctionDefinition, but pytest isnt there yet
    # sw we have to rely on a working solution
    pytest.mark.meta(from_docs=metadata)(obj)
    if metadata:
        test_path = get_rel_path(collector.fspath)
        logger.debug('Parsed docstring metadata on {} in {}'.format(name, test_path))
        logger.trace('{} doc metadata: {}'.format(name, str(metadata)))
예제 #2
0
파일: nelson.py 프로젝트: mkoura/cfme_tests
def pytest_pycollect_makeitem(collector, name, obj):
    """pytest hook that adds docstring metadata (if found) to a test's meta mark"""
    if not isinstance(obj, FunctionType):
        return

    # __doc__ can be empty or nonexistent, make sure it's an empty string in that case
    metadata = get_meta(obj)
    # this is just bad - apply the marks better once we go pytest 3.6+
    # ideally we would check a FunctionDefinition, but pytest isnt there yet
    # sw we have to rely on a working solution
    pytest.mark.meta(from_docs=metadata)(obj)
    if metadata:
        test_path = get_rel_path(collector.fspath)
        logger.debug('Parsed docstring metadata on {} in {}'.format(name, test_path))
        logger.trace('{} doc metadata: {}'.format(name, str(metadata)))
예제 #3
0
def pytest_pycollect_makeitem(collector, name, obj):
    """pytest hook that adds docstring metadata (if found) to a test's meta mark"""
    if not isinstance(obj, FunctionType) and not hasattr(obj, 'meta'):
        # This relies on the meta mark having already been applied to
        # all test functions before this hook is called
        return

    # __doc__ can be empty or nonexistent, make sure it's an empty string in that case
    metadata = get_meta(obj)

    if not hasattr(obj.meta, 'kwargs'):
        obj.meta.kwargs = dict()
    obj.meta.kwargs.update({'from_docs': metadata})
    if metadata:
        test_path = get_rel_path(collector.fspath)
        logger.debug('Parsed docstring metadata on {} in {}'.format(
            name, test_path))
        logger.trace('{} doc metadata: {}'.format(name, str(metadata)))
예제 #4
0
def pytest_pycollect_makeitem(collector, name, obj):
    """pytest hook that adds docstring metadata (if found) to a test's meta mark"""
    if not isinstance(obj, FunctionType) and not hasattr(obj, 'meta'):
        # This relies on the meta mark having already been applied to
        # all test functions before this hook is called
        return

    # __doc__ can be empty or nonexistent, make sure it's an empty string in that case
    metadata = get_meta(obj)

    if not hasattr(obj.meta, 'kwargs'):
        obj.meta.kwargs = dict()
    obj.meta.kwargs.update({
        'from_docs': metadata
    })
    if metadata:
        test_path = get_rel_path(collector.fspath)
        logger.debug('Parsed docstring metadata on {} in {}'.format(name, test_path))
        logger.trace('{} doc metadata: {}'.format(name, str(metadata)))