From 186b40de54e3b294b2ee81c87c44acf5c25b1c17 Mon Sep 17 00:00:00 2001 From: Andres Riancho Date: Thu, 26 Dec 2013 13:52:03 -0300 Subject: [PATCH] All tests pass! Fixes https://github.com/spulec/moto/issues/72 --- moto/core/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/moto/core/models.py b/moto/core/models.py index dd1f3794..e3777741 100644 --- a/moto/core/models.py +++ b/moto/core/models.py @@ -25,6 +25,7 @@ class MockAWS(object): self.stop() def start(self): + self.__class__.nested_count += 1 self.backend.reset() if not HTTPretty.is_enabled(): @@ -48,6 +49,9 @@ class MockAWS(object): def stop(self): self.__class__.nested_count -= 1 + if self.__class__.nested_count < 0: + raise RuntimeError('Called stop() before start().') + if self.__class__.nested_count == 0: HTTPretty.disable()