mercredi 24 juin 2015

In a Django test, how to load a sample JSON file?

I'm writing tests for a Django app that fetches and parses JSON data from an API. I want to test the parsing by giving the method a known, sample JSON file. Two questions:

  1. Where would it be best to put this? It's not quite a fixture, so I'm not sure if putting it in my app's fixtures/ directory will be confusing.
  2. I know I can load the file using open() but how should I specify the correct filepath in a way that will be robust?

Aucun commentaire:

Enregistrer un commentaire