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(['test1', 'test2'])
44 _test_files_exist(['test1', 'test2'])
45 os.utime('test2', (0, 0))
46 assert os.system("remove-old-files.py --older 100 .") == 0
47 _test_files_exist(['test1'])
48 _test_files_not_exist(['test2'])
52 create_files(['test3', 'test4'], 'subdir')
53 test3 = os.path.join('subdir', 'test3')
54 test4 = os.path.join('subdir', 'test4')
55 _test_files_exist([test3, test4])
56 os.utime(test4, (0, 0))
57 assert os.system("remove-old-files.py --older 100 .") == 0
58 _test_files_exist([test3])
59 _test_files_not_exist([test4])