Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit test fixtures in Python?

I'm writing a library in Python which makes calls to a REST API, receives results in JSON, and returns Python class instances after transforming the results.

Is there a generally accepted way of including test fixtures (ie JSON files to test against) inside of the Python package and test namespace to load and test against in your test cases?

like image 678
Naftuli Kay Avatar asked Nov 21 '22 10:11

Naftuli Kay


1 Answers

You could try using the mock module. and mock the request.get like in this post Mock, UnitTest, JSON

like image 144
m3lhIN400Forty4 Avatar answered Nov 24 '22 00:11

m3lhIN400Forty4