1 """PPU test utilities"""
7 from tempfile import mkdtemp
17 os.chdir(os.sep) # To the root of the FS
18 shutil.rmtree(tmp_dir, ignore_errors=True)
21 def find_in_path(name):
22 for path in os.environ["PATH"].split(os.pathsep):
23 path = path.strip('"')
24 test_prog_path = os.path.join(path, name)
25 if os.path.exists(test_prog_path):
27 sys.exit("Cannot find %s in %s" % (name, os.environ["PATH"]))
30 def create_files(files, subdirectory=None):
32 os.makedirs(subdirectory)
36 with open(os.path.join(subdirectory, fname), 'w'):
40 def assert_files_exist(files):
41 if isinstance(files, str):
44 assert os.path.exists(fname)
47 def assert_files_not_exist(files):
48 if isinstance(files, str):
51 assert not os.path.exists(fname)