I have two functions running at the same time(simultaneously). I want to write my test inside one of them. I mean I want to run my test's simultaneously with my other function. Because my other function creates fake data such as it creates votes if that turn is "night". So my test file is stated below. How can I run my test simultaneously with other function.
def function1():
call_command('fake')
def function2():
# some codes here
# I also want to write my tests here because I need to fake command is running
# while my test's running
thread1 = Thread(target=function1)
thread2 = Thread(target=function2)
thread1.start()
thread2.start()
time.sleep(10)
fake data generator is stated below
while room.status != 'Finished':
if turn and turn.type == 'Day'
sleep(0.5)
to_be_killed = RoomPlayer.objects.filter(
room=room).filter(alive=True).order_by("?")[0]
Vote.objects.create(
day=turn, voter=room_players[j], voted=to_be_killed)
Aucun commentaire:
Enregistrer un commentaire