from testfixtures import TempDirectory def test_tempdir(): with TempDirectory() as d: file_path = d.write('test.txt', 'Hello, world!') assert d.read('test.txt') == 'Hello, world!'In this example, we create a new temporary directory and write a file called "test.txt" with the contents "Hello, world!". We then assert that the contents of the file match what we expect. testfixtures is the package library for the TempDirectory class.