diff --git a/stripe/stripe_object.py b/stripe/stripe_object.py index 1c965f6ec..28a5e03be 100644 --- a/stripe/stripe_object.py +++ b/stripe/stripe_object.py @@ -98,12 +98,11 @@ def __setitem__(self, k, v): "You may set %s.%s = None to delete the property" % ( k, str(self), k)) - if not hasattr(self, k) or v != getattr(self, k): - # Allows for unpickling in Python 3.x - if not hasattr(self, '_unsaved_values'): - self._unsaved_values = set() + # Allows for unpickling in Python 3.x + if not hasattr(self, '_unsaved_values'): + self._unsaved_values = set() - self._unsaved_values.add(k) + self._unsaved_values.add(k) super(StripeObject, self).__setitem__(k, v) diff --git a/tests/api_resources/abstract/test_updateable_api_resource.py b/tests/api_resources/abstract/test_updateable_api_resource.py index 6c288315f..4091f16df 100644 --- a/tests/api_resources/abstract/test_updateable_api_resource.py +++ b/tests/api_resources/abstract/test_updateable_api_resource.py @@ -16,7 +16,8 @@ def setUp(self): 'post', '/v1/myupdateables/myid', { - 'thats': 'it' + 'id': 'myid', + 'thats': 'it', } ) @@ -83,17 +84,35 @@ def test_save(self): self.checkSave() self.assert_no_request() - # Setting the same value should not cause any request. + # Setting the same value should cause a request. + self.stub_request( + 'post', + '/v1/myupdateables/myid', + { + 'id': 'myid', + 'thats': 'it', + } + ) + self.obj.thats = 'it' self.checkSave() - self.assert_no_request() + + self.assert_requested( + 'post', + '/v1/myupdateables/myid', + { + 'thats': 'it', + }, + None + ) # Changing the value should cause a request. self.stub_request( 'post', '/v1/myupdateables/myid', { - 'thats': 'it' + 'id': 'myid', + 'thats': 'it', } )