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
  • 121,510
  • 29
  • 395
  • 339
user1584421
  • 3,499
  • 11
  • 46
  • 86

1 Answers1

1

You could use an f-string:

fileName = 'myFile.txt'
# ...
assert response.headers['Content-Disposition'] == f'attachment; filename={fileName}'
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206