Now I understand your point
and actually, I build up the dictionary as you suggest in doctest and the debugs show I get the {{ notation:
list_test = [{'file: '+ basename(pathfilename), 'test: ' + test_function_name , 'line: ' + str(lineno_parentfunc)}]
print('\n############ list_test =' + str(list_test))
fq_apiname = full_name_with_qualname(testedapi)
print('\n############ fq_apiname =' + str(fq_apiname))
if(fq_apiname in RegisterTestsperAPI.apiTestsMap):
RegisterTestsperAPI.apiTestsMap[fq_apiname] = RegisterTestsperAPI.apiTestsMap[fq_apiname] + list_test
else:
RegisterTestsperAPI.apiTestsMap[fq_apiname] = list_test
print('\n############ RegisterTestsperAPI.apiTestsMap[fq_apiname] =' + str(RegisterTestsperAPI.apiTestsMap[fq_apiname]))
Can see in conftest the json.dump method changes it from [{ to [[. Not sure if that is python standard or I could impact that - maybe also that default function has an impact but I cant quite figure out how.
conftest: fastaidoctestexchange/conftest.py at master · Benudek/fastaidoctestexchange · GitHub
def set_default(obj):
if isinstance(obj, set):
return list(obj)
raise TypeError
def stop_doctest_collector():
fastai_dir = abspath(join(dirname( __file__ ), '..', 'fastai'))
print('################ RegisterTestsperAPI.apiTestsMap: ' + str(RegisterTestsperAPI.apiTestsMap))
with open(fastai_dir + '/TestAPIRegister.json', 'w') as f:
json.dump(obj=RegisterTestsperAPI.apiTestsMap,fp=f, indent = 4, sort_keys= True, default=set_default )
At least, revisiting the code I generate a better readable version now
TestAPIRegister.json: fastaidoctestexchange/TestAPIRegister.json at master · Benudek/fastaidoctestexchange · GitHub
Happy for pointers, otherwise I understood we can handle the array [[?