5 from tempfile import mkdtemp
18 os.chdir(os.sep) # To the root of the FS
19 shutil.rmtree(tmp_dir)
22 def create_files(files, subdirectory=None):
24 os.makedirs(subdirectory)
28 with open(os.path.join(subdirectory, fname), 'w'):
32 def _test_files_exist(files):
34 assert os.path.exists(fname)
37 def _test_files_not_exist(files):
39 assert not os.path.exists(fname)
43 create_files(['test'])
44 os.utime('test', (0, 0))
45 _test_files_exist(['test'])
46 assert os.system("remove-old-files.py --older 100 .") == 0
47 _test_files_not_exist(['test'])
51 create_files(['test2'], 'subdir')
52 test_file = os.path.join('subdir', 'test2')
53 os.utime(test_file, (0, 0))
54 _test_files_exist([test_file])
55 assert os.system("remove-old-files.py --older 100 .") == 0
56 _test_files_not_exist([test_file])