X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=tests%2Ftest_rm.py;h=76937e516245f8d8633cab4321d341fc6e46c4a6;hb=1c8100c4383ad47d1e1f88e8b92d1ddb371eff8f;hp=631502cfe096c4531cfd2f80364bbcaafa4f8662;hpb=e833f2fdc5164b9a9403baa2ee10cae2003cec88;p=ppu.git diff --git a/tests/test_rm.py b/tests/test_rm.py index 631502c..76937e5 100755 --- a/tests/test_rm.py +++ b/tests/test_rm.py @@ -1,17 +1,12 @@ #! /usr/bin/env python -import os import subprocess import sys from ppu_tu import setup, teardown, find_in_path # noqa from ppu_tu import create_files, assert_files_exist, assert_files_not_exist -tmp_dir = None - test_prog_path = find_in_path('rm.py') -if not test_prog_path: - sys.exit("Cannot find rm.py in %s" % os.environ["PATH"]) def test_rm(): @@ -21,3 +16,32 @@ def test_rm(): [sys.executable, test_prog_path, "test2"]) == 0 assert_files_exist('test1') assert_files_not_exist('test2') + + create_files(['test1', 'test2']) + assert_files_exist(['test1', 'test2']) + assert subprocess.call( + [sys.executable, test_prog_path, "-r", "test2"]) == 0 + assert_files_exist('test1') + assert_files_not_exist('test2') + + assert subprocess.call( + [sys.executable, test_prog_path, "test3"]) == 1 # not exists + assert subprocess.call( + [sys.executable, test_prog_path, "-f", "test3"]) == 0 + + +def test_rm_recursive(): + create_files(['test']) + create_files(['test'], 'subdir/subd2') + assert_files_exist(['test', 'subdir/subd2/test']) + assert subprocess.call( + [sys.executable, test_prog_path, "subdir"]) == 1 + assert subprocess.call( + [sys.executable, test_prog_path, "-r", "subdir"]) == 0 + assert_files_exist('test') + assert_files_not_exist(['subdir/subd2/test']) + + assert subprocess.call( + [sys.executable, test_prog_path, "-r", "test3"]) == 1 # not exists + assert subprocess.call( + [sys.executable, test_prog_path, "-rf", "test3"]) == 0