Add test for ThreadLocalSingleton prodiver reset functionality

This commit is contained in:
Jeroen Rietveld 2019-03-21 09:28:52 +01:00
parent b0efb5eecc
commit dc40ad84b5

View File

@ -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):