docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a configuration management system that uses slotted classes for memory efficiency. The system should serialize and deserialize configuration objects that use __slots__ to optimize memory usage in resource-constrained environments.
Implement a configuration system with the following components:
ServerConfig class: A slotted class that stores server configuration
__slots__ to define exactly these attributes: host, port, timeoutDatabaseConfig class: A slotted class that stores database configuration
__slots__ to define exactly these attributes: connection_string, pool_size, retry_attemptsApplicationConfig class: A slotted class that combines both server and database configs
__slots__ to define exactly these attributes: app_name, server, databaseserver attribute should hold a ServerConfig instancedatabase attribute should hold a DatabaseConfig instancesrc/config_manager.pytest/test_config_serialization.pyAll test cases should be implemented in test/test_config_serialization.py:
Serialize a ServerConfig instance with host="localhost", port=8080, timeout=30 to a dictionary and verify the result contains all three attributes with correct values @test
Deserialize a dictionary {"host": "api.example.com", "port": 443, "timeout": 60} into a ServerConfig instance and verify all attributes are correctly set @test
Serialize a DatabaseConfig instance with connection_string="postgresql://localhost/db", pool_size=10, retry_attempts=3 to a dictionary and verify all attributes are present @test
Deserialize a dictionary {"connection_string": "mysql://localhost/app", "pool_size": 5, "retry_attempts": 2} into a DatabaseConfig instance and verify all attributes match @test
Serialize an ApplicationConfig instance containing nested ServerConfig and DatabaseConfig objects, and verify the output dictionary contains correctly nested structures @test
Deserialize a nested dictionary structure into an ApplicationConfig instance and verify that both the app_name and nested server and database configurations are correctly reconstructed @test
A Python serialization/deserialization library for converting Python objects to and from JSON-compatible dictionaries. Provides support for slotted classes and nested object serialization.