Пример #1
0
    def _add_item_hier_parts_parametrize(item,
                                         report_parts,
                                         tests_parts,
                                         rp_name=""):

        for mark in item.own_markers:
            if mark.name == 'parametrize':
                ch_index = item.nodeid.find("[")
                test_fullname = item.nodeid[:ch_index if ch_index > 0 else len(
                    item.nodeid)]
                test_name = item.originalname

                rp_name += ("::" if rp_name else "") + test_name

                if test_fullname in tests_parts:
                    item_test = tests_parts[test_fullname]
                else:
                    item_test = Item(test_fullname,
                                     nodeid=test_fullname,
                                     session=item.session,
                                     config=item.session.config)
                    item_test._rp_name = rp_name
                    item_test.obj = item.obj
                    item_test.keywords = item.keywords
                    item_test.own_markers = item.own_markers
                    item_test.parent = item.parent

                    tests_parts[test_fullname] = item_test

                rp_name = ""
                report_parts.append(item_test)
                break

        return rp_name
Пример #2
0
def test_generic_path(testdir):
    from _pytest.main import Session
    config = testdir.parseconfig()
    session = Session(config)
    p1 = Node('a', config=config, session=session)
    # assert p1.fspath is None
    p2 = Node('B', parent=p1)
    p3 = Node('()', parent=p2)
    item = Item('c', parent=p3)

    res = generic_path(item)
    assert res == 'a.B().c'

    p0 = FSCollector('proj/test', config=config, session=session)
    p1 = FSCollector('proj/test/a', parent=p0)
    p2 = Node('B', parent=p1)
    p3 = Node('()', parent=p2)
    p4 = Node('c', parent=p3)
    item = Item('[1]', parent=p4)

    res = generic_path(item)
    assert res == 'test/a:B().c[1]'
Пример #3
0
def test_generic_path(testdir):
    from _pytest.main import Session

    config = testdir.parseconfig()
    session = Session(config)
    p1 = Node("a", config=config, session=session, nodeid="a")
    # assert p1.fspath is None
    p2 = Node("B", parent=p1)
    p3 = Node("()", parent=p2)
    item = Item("c", parent=p3)

    res = generic_path(item)
    assert res == "a.B().c"

    p0 = FSCollector("proj/test", config=config, session=session)
    p1 = FSCollector("proj/test/a", parent=p0)
    p2 = Node("B", parent=p1)
    p3 = Node("()", parent=p2)
    p4 = Node("c", parent=p3)
    item = Item("[1]", parent=p4)

    res = generic_path(item)
    assert res == "test/a:B().c[1]"
Пример #4
0
    def _add_item_hier_parts_parametrize(item, report_parts, tests_parts,
                                         rp_name=""):
        """
        Add item to hierarchy of parents with params.

        :param item:         pytest.Item
        :param report_parts: Parent reports
        :param tests_parts:  test item parts
        :param rp_name:      name of report
        :return: str rp_name
        """
        for mark in item.own_markers:
            if mark.name == 'parametrize':
                ch_index = item.nodeid.find("[")
                test_fullname = item.nodeid[
                                :ch_index if ch_index > 0 else len(
                                    item.nodeid)]
                test_name = item.originalname

                rp_name += ("::" if rp_name else "") + test_name

                if test_fullname in tests_parts:
                    item_test = tests_parts[test_fullname]
                else:
                    if hasattr(Item, "from_parent"):
                        item_test = Item.from_parent(parent=item,
                                                     name=test_fullname,
                                                     nodeid=test_fullname)
                    else:
                        item_test = Item(test_fullname, nodeid=test_fullname,
                                         session=item.session,
                                         config=item.session.config)
                    item_test._rp_name = rp_name
                    item_test.obj = item.obj
                    item_test.keywords = item.keywords
                    item_test.own_markers = item.own_markers
                    item_test.parent = item.parent

                    tests_parts[test_fullname] = item_test

                rp_name = ""
                report_parts.append(item_test)
                break

        return rp_name