def test_collect_imports_disabled(pytester: Pytester) -> None:
    """
    When collect_imported_tests is disabled, only objects in the
    test modules are collected as tests, so the imported names (`Testament` and `test_testament`)
    are not collected.
    """
    pytester.makeini(
        """
        [pytest]
        collect_imported_tests = false
        """
    )

    setup_files(pytester)
    result = pytester.runpytest("-v", "tests")
    result.stdout.fnmatch_lines(
        [
            "tests/foo_test.py::TestDomain::test PASSED*",
        ]
    )

    # Ensure that the hooks were only called for the collected item.
    reprec = result.reprec  # type:ignore[attr-defined]
    reports = reprec.getreports("pytest_collectreport")
    [modified] = reprec.getcalls("pytest_collection_modifyitems")
    [item_collected] = reprec.getcalls("pytest_itemcollected")

    assert [x.nodeid for x in reports] == [
        "",
        "tests/foo_test.py::TestDomain",
        "tests/foo_test.py",
        "tests",
    ]
    assert [x.nodeid for x in modified.items] == ["tests/foo_test.py::TestDomain::test"]
    assert item_collected.item.nodeid == "tests/foo_test.py::TestDomain::test"

    When collect_imported_tests is disabled, only objects in the
    test modules are collected as tests, so the imported names (`Testament` and `test_testament`)
    are not collected.
    
testing/test_collect_imported_tests.py