mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-18 03:52:19 +03:00
Add test for ThreadLocalSingleton prodiver reset functionality
This commit is contained in:
parent
b0efb5eecc
commit
dc40ad84b5
|
@ -347,7 +347,7 @@ class _BaseSingletonTestCase(object):
|
|||
provider.reset()
|
||||
|
||||
instance2 = provider()
|
||||
self.assertIsInstance(instance1, object)
|
||||
self.assertIsInstance(instance2, object)
|
||||
|
||||
self.assertIsNot(instance1, instance2)
|
||||
|
||||
|
@ -397,6 +397,19 @@ class ThreadLocalSingletonTests(_BaseSingletonTestCase, unittest.TestCase):
|
|||
repr(Example),
|
||||
hex(id(provider))))
|
||||
|
||||
def test_reset(self):
|
||||
provider = providers.ThreadLocalSingleton(Example)
|
||||
|
||||
instance1 = provider()
|
||||
self.assertIsInstance(instance1, Example)
|
||||
|
||||
provider.reset()
|
||||
|
||||
instance2 = provider()
|
||||
self.assertIsInstance(instance2, Example)
|
||||
|
||||
self.assertIsNot(instance1, instance2)
|
||||
|
||||
|
||||
class DelegatedThreadLocalSingletonTests(_BaseSingletonTestCase,
|
||||
unittest.TestCase):
|
||||
|
|
Loading…
Reference in New Issue
Block a user