Dictionaries shared among unit tests

I was recently writing some unit tests for some data serializer methods for a third party market data API in Django and one of my tests used a dictionary to mock a JSON response from an API. I wanted to be DRY so I reused the same dictionary and using a few class properties, I modified the values to represent different scenarios where the data might be invalid (this API is not very stable). But I mistakenly reused that dictionary across a few tests without deepcopy causing test failures
Nabil Jamaleddine | 2016-12-20 #django #tests #dictionaries #python

Checking if a object exists on save in Django

Having used integer primary keys for many projects, I've only recently switched over to using UUIDs on a few projects about a little less than a year ago. In the switch, an old solution I've often used for checking if an object exists, or is being created, has become obsolete.
Nabil Jamaleddine | 2016-06-01 #development #django #models