mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 09:57:37 +03:00 
			
		
		
		
	Cover shutdown of not initialized resource
This commit is contained in:
		
							parent
							
								
									fe583ac9cf
								
							
						
					
					
						commit
						0aaae89328
					
				| 
						 | 
				
			
			@ -169,6 +169,15 @@ class ResourceTests(unittest.TestCase):
 | 
			
		|||
        self.assertEqual(_init.init_counter, 2)
 | 
			
		||||
        self.assertEqual(_init.shutdown_counter, 2)
 | 
			
		||||
 | 
			
		||||
    def test_shutdown_of_not_initialized(self):
 | 
			
		||||
        def _init():
 | 
			
		||||
            yield
 | 
			
		||||
 | 
			
		||||
        provider = providers.Resource(_init)
 | 
			
		||||
 | 
			
		||||
        result = provider.shutdown()
 | 
			
		||||
        self.assertIsNone(result)
 | 
			
		||||
 | 
			
		||||
    def test_initialized(self):
 | 
			
		||||
        provider = providers.Resource(init_fn)
 | 
			
		||||
        self.assertFalse(provider.initialized)
 | 
			
		||||
| 
						 | 
				
			
			@ -461,6 +470,16 @@ class AsyncResourceTest(AsyncTestCase):
 | 
			
		|||
        self.assertEqual(_init.init_counter, 2)
 | 
			
		||||
        self.assertEqual(_init.shutdown_counter, 2)
 | 
			
		||||
 | 
			
		||||
    def test_shutdown_of_not_initialized(self):
 | 
			
		||||
        async def _init():
 | 
			
		||||
            yield
 | 
			
		||||
 | 
			
		||||
        provider = providers.Resource(_init)
 | 
			
		||||
        provider.enable_async_mode()
 | 
			
		||||
 | 
			
		||||
        result = self._run(provider.shutdown())
 | 
			
		||||
        self.assertIsNone(result)
 | 
			
		||||
 | 
			
		||||
    def test_concurrent_init(self):
 | 
			
		||||
        resource = object()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user