tessl install tessl/pypi-rodi@2.0.0Implementation of dependency injection for Python 3
Agent Success
Agent success rate when using this tile
92%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.06x
Baseline
Agent success rate without this tile
87%
Build a simple configuration management system that maintains shared application settings throughout the application's lifetime. The system should ensure that configuration objects are created only once and reused across all components that need them.
Implement a configuration management system with the following components:
AppConfig class: A simple configuration holder with the following attributes:
app_name: string representing the application nameversion: string representing the version numberdebug_mode: boolean flag for debug modeThe class should be initialized with these three parameters.
DatabaseConfig class: A configuration holder for database settings with:
host: string for database hostport: integer for database portdatabase_name: string for the database nameThe class should be initialized with these three parameters.
Application class: A class that uses AppConfig. It should:
get_app_info() that returns a string in the format: "{app_name} v{version} (debug: {debug_mode})"DatabaseConnection class: A class that uses DatabaseConfig. It should:
get_connection_string() that returns a string in the format: "{host}:{port}/{database_name}"Service registration and resolution:
Provides dependency injection capabilities for Python applications.
File: test_config_manager.py
Create the following setup:
Register both configuration instances as shared singletons, then register Application and DatabaseConnection classes. Resolve Application twice and verify:
get_app_info() returns "MyApp v1.0.0 (debug: True)"get_app_info() returns "MyApp v1.0.0 (debug: True)"is operator)File: test_config_manager.py
Using the same configuration from Test 1, resolve DatabaseConnection twice and verify:
get_connection_string() returns "localhost:5432/mydb"get_connection_string() returns "localhost:5432/mydb"is operator)File: test_config_manager.py
Using the same setup, resolve both Application and DatabaseConnection, then:
get_app_info() returns "MyApp v1.0.0 (debug: False)"config_manager.py: Contains AppConfig, DatabaseConfig, Application, and DatabaseConnection classestest_config_manager.py: Contains all test cases