Пример #1
0
def pytest_collection(session: pytest.Session):
    session.items = []

    for filename, tests in groupby(coordinator.tests, key=lambda test: test['file']):
        file = MochaFile.from_parent(session, fspath=LocalPath(filename))

        for info in tests:
            requested_fixtures = ['live_server', '_live_server_helper']
            test = MochaTest.from_parent(
                file,
                name='::'.join(info['parents']),
                fixtureinfo=FuncFixtureInfo(
                    argnames=tuple(requested_fixtures),
                    initialnames=tuple(requested_fixtures),
                    names_closure=requested_fixtures,
                    name2fixturedefs={},
                ),
                keywords={
                    'django_db': pytest.mark.django_db(transaction=True),
                }
            )

            session.items.append(test)

    ###
    # NOTE: if this counter remains 0 at end of session, an exit code of 5 will be returned.
    #       This value is normally set by Session.perform_collect(), but we are bypassing that
    #       implementation.
    #
    session.testscollected = len(session.items)

    return session.items
Пример #2
0
def pytest_collection(session: pytest.Session):
    session.items = []

    for filename, tests in groupby(coordinator.tests, key=lambda test: test['file']):
        file = MochaFile(
            filename,
            parent=session,
            config=session.config,
            session=session,
        )

        for info in tests:
            requested_fixtures = ['live_server', '_live_server_helper']
            test = MochaTest(
                name='::'.join(info['parents']),
                parent=file,
                fixtureinfo=FuncFixtureInfo(
                    argnames=tuple(requested_fixtures),
                    initialnames=tuple(requested_fixtures),
                    names_closure=requested_fixtures,
                    name2fixturedefs={},
                ),
                keywords={
                    'django_db': pytest.mark.django_db(transaction=True),
                }
            )

            session.items.append(test)

    return session.items