Small question: What is the best way to write an i...
# general
r
Small question: What is the best way to write an integration test that “runs pants, modifies a file (that exists in the buildroot), runs pants again”? Currently my approach is to create a
temporary_workdir():
copy the relevant target there with the same path, and run pants on that.
a
Dorothy and I totally added a thing for this…
PantsRunIntegrationTest.temporary_file_content
Copy code
with self.temporary_file_content(path, content, binary_mode=False):
  pants_run = self.run_pants(command=command)
r
Ah
That is very cool!
a
Oh, that one deletes the file after the run, instead of restoring its original value… I’m sure we had one for that too…
r
Wait, but I want to edit a file that exists already
a
contextutil.with_overwritten_file_content
But apparently left the test method to do the writing of the new value, rather than the decorator… Could be nice to modify it to have a
temporary_contents
argument that does the writing for you too 🙂
r
Oh cool 🙂 Any idea why this is not in
PantsIntegrationTestBase
? It’s only ever used in tests
a
Feel free to move it 🙂
r
Cool, that sounds like a separate PR 🙂
a
Totally
r
Cool, I may have time to do that today
Also, thanks!