From e1b9158f67dc7673e9d84eaf9e3a5b73c21cb31a Mon Sep 17 00:00:00 2001 From: srghma Date: Sat, 16 Jun 2018 21:28:10 +0300 Subject: [PATCH] fix: tests.functional.test_vpc:test_deploy_vpc with json state -> TypeError expected string or buffer --- nixops/state/state_helper.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nixops/state/state_helper.py b/nixops/state/state_helper.py index 12bfa225e..f97bfaf26 100644 --- a/nixops/state/state_helper.py +++ b/nixops/state/state_helper.py @@ -25,12 +25,18 @@ def __setitem__(self, key, value): def __getitem__(self, key): value = self._state.get_resource_attr(self.uuid, self.id, key) - if value != nixops.util.undefined: + + if value == nixops.util.undefined: + raise KeyError("couldn't find key {} in the state file".format(key)) + + if isinstance(value, str): try: return json.loads(value) except ValueError: return value - raise KeyError("couldn't find key {} in the state file".format(key)) + + return value + def __delitem__(self, key): self._state.del_resource_attr(self.uuid, self.id, key)