0

I have this line:

assert response.headers['Content-Disposition'] == 'attachment; filename=myFile.txt'

In the second string of the line ('attachment; filename=myFile.txt')

I want to remove the hardcoded filename (myFile.txt) and replace it with a variable that i have.

Like printf() in C, in a way, replacing the string at that exact location with a variable.

davidism
  • 110,080
  • 24
  • 357
  • 317
user1584421
  • 2,957
  • 8
  • 33
  • 66

1 Answers1

1

You could use an f-string:

fileName = 'myFile.txt'
# ...
assert response.headers['Content-Disposition'] == f'attachment; filename={fileName}'
Mathias R. Jessen
  • 135,435
  • 9
  • 130
  • 184