- _test_files_exist([test3, test4])
- os.utime(test4, (0, 0))
- assert os.system("remove-old-files.py --older 100 .") == 0
- _test_files_exist([test3])
- _test_files_not_exist([test4])
+ assert_files_exist([test3, test4])
+ os.utime(test4, (old_time, old_time))
+ assert subprocess.call(
+ [sys.executable, test_prog_path, "--older", "100", "."]) == 0
+ assert_files_exist(test3)
+ assert_files_not_exist(test4)
+
+
+def test_remove_empty_directory():
+ create_files(['test3', 'test4'], 'subdir')
+ test3 = os.path.join('subdir', 'test3')
+ test4 = os.path.join('subdir', 'test4')
+ assert_files_exist([test3, test4])
+ os.utime(test3, (old_time, old_time))
+ os.utime(test4, (old_time, old_time))
+ assert subprocess.call(
+ [sys.executable, test_prog_path, "--older", "100", "."]) == 0
+ assert_files_exist('subdir')
+ assert_files_not_exist([test3, test4])
+ assert subprocess.call(
+ [sys.executable, test_prog_path, "-e", "--older", "100", "."]) == 0
+ assert_files_not_exist('subdir')