From dc40ad84b5dfcb30066a55ea24a6671916ff655e Mon Sep 17 00:00:00 2001 From: Jeroen Rietveld Date: Thu, 21 Mar 2019 09:28:52 +0100 Subject: [PATCH] Add test for ThreadLocalSingleton prodiver reset functionality --- tests/unit/providers/test_singletons_py2_py3.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/unit/providers/test_singletons_py2_py3.py b/tests/unit/providers/test_singletons_py2_py3.py index fcfb64ce..52ad1360 100644 --- a/tests/unit/providers/test_singletons_py2_py3.py +++ b/tests/unit/providers/test_singletons_py2_py3.py @@ -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):