Skip to content

Commit

Permalink
Merge dc40ad8 into 69602dc
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenrietveld committed Mar 21, 2019
2 parents 69602dc + dc40ad8 commit b876830
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/dependency_injector/providers.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dependency_injector/providers.pyx
Expand Up @@ -1808,7 +1808,7 @@ cdef class ThreadLocalSingleton(BaseSingleton):
:rtype: None
"""
self.__storage.instance = None
del self.__storage.instance

cpdef object _provide(self, tuple args, dict kwargs):
"""Return single instance."""
Expand Down
15 changes: 14 additions & 1 deletion tests/unit/providers/test_singletons_py2_py3.py
Expand Up @@ -347,7 +347,7 @@ def test_reset(self):
provider.reset()

instance2 = provider()
self.assertIsInstance(instance1, object)
self.assertIsInstance(instance2, object)

self.assertIsNot(instance1, instance2)

Expand Down Expand Up @@ -397,6 +397,19 @@ def test_repr(self):
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):
Expand Down

0 comments on commit b876830

Please sign in to comment.