My favorites | Sign in
Project Logo
                
Details: Show all Hide all

Last 30 days

  • Nov 20, 2009
    issue 11 (Singletons should be scope of the injector) reported by mark.chadwick   -   What steps will reproduce the problem? 1. Create an injector to build my instances (somewhere there's a Singleton) 2. Teardown what I'm doing, create a new injector, create new instances What is the expected output? What do you see instead? Singleton instances are the same instances across injectors. I would expect all singletons created from the same injector to be equal, but singletons created from different injectors to be different instances. What version of the product are you using? On what operating system? 0.2.1dev rev d28d5e34beb6 on Ubuntu 8.10, Python 2.5.2 Please provide any additional information below. Though a running system should never be strung together by multiple injectors, this is a common pattern in tests. In the setup method, create an injector with a TestModule, pull out the instances you'd like to test, then test them. This is extraordinarily convenient when dealing with Singletons because they hold some state almost by definition. IMHO, one of the big wins of using DI is isolated tests without complicated tearDown procedures to reset the system's state. I'm not intimately familiar with the source, but I believe a reasonable way to fix this is to attach GuiceData instances to the Injector instead of the class. If this sounds reasonable to the author (and he/she agrees this is the expected behavior), I'd be more than happy to implement the patch. I have attached a failing test.
    What steps will reproduce the problem? 1. Create an injector to build my instances (somewhere there's a Singleton) 2. Teardown what I'm doing, create a new injector, create new instances What is the expected output? What do you see instead? Singleton instances are the same instances across injectors. I would expect all singletons created from the same injector to be equal, but singletons created from different injectors to be different instances. What version of the product are you using? On what operating system? 0.2.1dev rev d28d5e34beb6 on Ubuntu 8.10, Python 2.5.2 Please provide any additional information below. Though a running system should never be strung together by multiple injectors, this is a common pattern in tests. In the setup method, create an injector with a TestModule, pull out the instances you'd like to test, then test them. This is extraordinarily convenient when dealing with Singletons because they hold some state almost by definition. IMHO, one of the big wins of using DI is isolated tests without complicated tearDown procedures to reset the system's state. I'm not intimately familiar with the source, but I believe a reasonable way to fix this is to attach GuiceData instances to the Injector instead of the class. If this sounds reasonable to the author (and he/she agrees this is the expected behavior), I'd be more than happy to implement the patch. I have attached a failing test.

Earlier this year

Older

  • Nov 29, 2008
    r42 (Merging the child_injector branch.) committed by roninds   -   Merging the child_injector branch.
    Merging the child_injector branch.
  • Nov 29, 2008
    r41 (Small name refactoring.) committed by roninds   -   Small name refactoring.
    Small name refactoring.
  • Nov 29, 2008
    r40 (Moving the scope implementation to be a little closer to the...) committed by roninds   -   Moving the scope implementation to be a little closer to the real Guice.
    Moving the scope implementation to be a little closer to the real Guice.
  • Nov 29, 2008
    r39 (Enable figleaf coverage in pavement.) committed by roninds   -   Enable figleaf coverage in pavement.
    Enable figleaf coverage in pavement.
  • Nov 29, 2008
    r38 (Began to add support for figleaf coverage. No network access...) committed by roninds   -   Began to add support for figleaf coverage. No network access to get figleaf right now.
    Began to add support for figleaf coverage. No network access to get figleaf right now.
  • Nov 29, 2008
    r37 (Updating the TODOs.) committed by roninds   -   Updating the TODOs.
    Updating the TODOs.
  • Nov 29, 2008
    r36 (Removing an unused class.) committed by roninds   -   Removing an unused class.
    Removing an unused class.
  • Nov 29, 2008
    r35 (Renaming InstanceProvider to SimpleProvider. Fixing and addi...) committed by roninds   -   Renaming InstanceProvider to SimpleProvider. Fixing and adding a test for injecting a provider.
    Renaming InstanceProvider to SimpleProvider. Fixing and adding a test for injecting a provider.
 
Hosted by Google Code