Session Ready
Exercise

Goons over my shammy

You are many light years from earth. Python programming aliens (Goons) abducted you and are forcing you to wash computer monitors. Goons keep stepping on your shammy (towel) and stopping you from working. You tell the Goons if they quit stepping on your shammy, you will write a Python script that programmatically creates self-destructing files and directories.

One of the uses for self-destructing files is to create integration tests. Integration tests can use temporary directory and files as a way of validating that processes in an application is doing what is expected. They tell you, "you had us at self-destruction". The tempfile and os module have been imported for you. Remember that tempfile.NameTemporaryFile object has many useful methods on it including .name.

Instructions
100 XP
  • Use tempfile.NamedTemporaryFile to create a named temporary file.
  • Write a message to it and verify it was written.
  • Verify temporary file was destroyed using os.path.exists.