def test_make_scratch_file_1 (self): """Make a scratch file in the tempdir""" ## Preparations: new_file = 'foo.txt' ## Main: f = scratchfile.make_scratch_file (new_file) assert (f.startswith (tempfile.tempdir)) assert (f.endswith ('foo.txt')) assert (not os.path.exists (f)) outfile = open (f, 'w') outfile.write ("bar") outfile.close() assert (os.path.exists (f)) os.remove (f)
def test_make_scratch_file_2 (self): """Make a scratch file in a supplied dir""" ## Preparations: new_file = 'foo.txt' new_dir = 'test_make_scratch_file_2' scratch_dir = os.path.join (self.testdir, new_dir) os.mkdir (scratch_dir) ## Main: f = scratchfile.make_scratch_file (new_file, scratch_dir) assert (f.startswith (scratch_dir)) assert (f.endswith (new_file)) assert (not os.path.exists (f)) outfile = open (f, 'w') outfile.write ("bar") outfile.close() assert (os.path.exists (f))