]> git.phdru.name Git - ppu.git/blob - tests/test_rm.py
4e4cd76d314412f7fc2c1215f3832965aa0a73f4
[ppu.git] / tests / test_rm.py
1 #! /usr/bin/env python
2
3 import os
4 import subprocess
5 import sys
6 from ppu_tu import setup, teardown, find_in_path  # noqa
7 from ppu_tu import create_files, assert_files_exist, assert_files_not_exist
8
9
10 tmp_dir = None
11
12 test_prog_path = find_in_path('rm.py')
13 if not test_prog_path:
14     sys.exit("Cannot find rm.py in %s" % os.environ["PATH"])
15
16
17 def test_rm():
18     create_files(['test1', 'test2'])
19     assert_files_exist(['test1', 'test2'])
20     assert subprocess.call(
21         [sys.executable, test_prog_path, "test2"]) == 0
22     assert_files_exist('test1')
23     assert_files_not_exist('test2')
24
25     create_files(['test1', 'test2'])
26     assert_files_exist(['test1', 'test2'])
27     assert subprocess.call(
28         [sys.executable, test_prog_path, "-r", "test2"]) == 0
29     assert_files_exist('test1')
30     assert_files_not_exist('test2')
31
32
33 def test_rm_recursive():
34     create_files(['test'])
35     create_files(['test'], 'subdir/subd2')
36     assert_files_exist(['test', 'subdir/subd2/test'])
37     assert subprocess.call(
38         [sys.executable, test_prog_path, "subdir"]) == 1
39     assert subprocess.call(
40         [sys.executable, test_prog_path, "-r", "subdir"]) == 0
41     assert_files_exist('test')
42     assert_files_not_exist(['subdir/subd2/test'])