]> git.phdru.name Git - ppu.git/commitdiff
Add rm.py
authorOleg Broytman <phd@phdru.name>
Sun, 30 Apr 2017 17:15:00 +0000 (20:15 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 30 Apr 2017 17:28:27 +0000 (20:28 +0300)
docs/index.rst
rm.py [new file with mode: 0755]
setup.py
tests/test_rm.py [new file with mode: 0755]

index 2da73c2b951713ac8a5836ef3998d5af44c872c5..4605aaa1e8a1fba8488542ed89aee2b0b4768eca 100644 (file)
@@ -45,6 +45,15 @@ Options::
                            remove files older than this number of days;
                            this is a required option
 
+rm.py
+~~~~~
+
+Remove files.
+
+Usage::
+
+    rm.py file1 [file2...]
+
 Indices and tables
 ==================
 
diff --git a/rm.py b/rm.py
new file mode 100755 (executable)
index 0000000..4278fef
--- /dev/null
+++ b/rm.py
@@ -0,0 +1,7 @@
+#! /usr/bin/env python
+
+import os
+import sys
+
+for filename in sys.argv[1:]:
+    os.unlink(filename)
index 88b510d56693574cd9bc5f991fc9fab168798628..b28471793ff3eb85068a0e910521d56d941e1ace 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -31,5 +31,5 @@ setup(name='ppu',
           'Programming Language :: Python :: 3.5',
           'Programming Language :: Python :: 3.6',
       ],
-      scripts=['cmp.py', 'remove-old-files.py'],
+      scripts=['cmp.py', 'remove-old-files.py', 'rm.py'],
       )
diff --git a/tests/test_rm.py b/tests/test_rm.py
new file mode 100755 (executable)
index 0000000..631502c
--- /dev/null
@@ -0,0 +1,23 @@
+#! /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():
+    create_files(['test1', 'test2'])
+    assert_files_exist(['test1', 'test2'])
+    assert subprocess.call(
+        [sys.executable, test_prog_path, "test2"]) == 0
+    assert_files_exist('test1')
+    assert_files_not_exist('test2')