Problem Statement:
In the given pytest testing codebase, there is comprehensive handling and testing of fixture resolution, parametrization, and dependencies, as well as test collection and module handling. However, there is an opportunity to improve error reporting quality and traceability when a fixture dependency lookup fails due to indirect parametrization or multiple layers of fixture overrides, especially in scenarios involving parametrized fixtures overridden at different levels (e.g., module level vs. conftest vs. class level).
Your task is to enhance the pytest framework's error reporting mechanism so that when a fixture dependency is not found or cannot be resolved (particularly in the presence of indirect parametrization and fixture overrides), the error messages provide richer contextual information. Specifically, the error should include:
1. The precise location (source file and line number) of the test function or fixture that caused the lookup failure.
2. The call chain of fixtures leading to the unresolved fixture dependency, including which fixtures were overridden and where.
3. The parametrization states of the relevant fixtures and how indirect parametrization contributed to the failure.
This enhancement should integrate with pytest's fixture resolution, request, and test collection mechanisms to gather the necessary context. It should also consider cases of overridden fixtures at various scopes (module, class, conftest, plugin) and dynamic fixture parametrization.
Requirements:
- Modify the fixture lookup and resolution error handling to include detailed context (call chain, source locations, parametrization states).
- Ensure the error messages are displayed cleanly as part of test collection or setup failure output.
- Integrate with the existing test reporting infrastructure to display the additional info without disrupting existing formatting.
- Maintain backward compatibility so tests without errors behave unchanged.
- Write new tests to cover scenarios where complex fixture dependency failures occur, confirming the enhanced error messages.
This problem requires modifying error handling and message generation in the fixture management system together with adjusting test collection and reporting, making use of APIs related to fixtures, requests, test items, and collection nodes.