import requests def exos(nb, username, password): rr = requests.post('http://localhost:8002/register', data={"username": username, 'password': password, 'password_confirm': password}) token = rr.json()['access_token'] for i in range(nb): r = requests.post('http://localhost:8002/exercices', data={"name": "FakingTest" + str(i), "consigne": "consigne", "private": False}, files={ 'file': ('test.py', open('./tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token}) print('DONE') exos(100, "lilianTest", "Pomme937342")