import json import csv import unittest import app class MyAppCase(unittest.TestCase): def setUp(self): app.app.config['TESTING'] = True self.app = app.app.test_client() def load_data(self): data=[] with open('address.csv') as fr: data_reader=csv.reader(fr) data=list(data_reader) data.pop(0) fr.close() return data def test_dummy(self): test_data=self.load_data() c=1 for i in test_data: try: print('--------------------------') print(c) response=self.app.post('/dsu', data={'addr':i[0]}) result = json.loads(response.get_data(as_text=True)) self.assertEqual(result[0]['district']+result[0]['sub_district'],i[1].strip()+i[2].strip()) except Exception as e: print(i) input("Press Enter to continue...") continue c+=1 if __name__=='__main__': unittest.main()