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