Advanced Scenarios

If the basic examples don’t cover your needs, check out our test files - they’re basically a cookbook of real-world scenarios:

1. test_injectable.py - Shows all possible combinations of:

  • Sync/async functions

  • Decorator vs function wrapping

  • Caching vs no caching

2. test_integration.py - Demonstrates:

  • Resource cleanup

  • Generator dependencies

  • Mixed sync/async dependencies

  • Multiple dependency chains

These test cases mirror common development patterns you’ll encounter. They show how to handle complex dependency trees, resource management, and mixing sync/async code - stuff you’ll actually use in production.

The test files are written to be self-documenting, so browsing through them will give you practical examples for most scenarios you’ll face in your codebase.