From e833f2fdc5164b9a9403baa2ee10cae2003cec88 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 30 Apr 2017 20:15:00 +0300 Subject: [PATCH] Add rm.py --- docs/index.rst | 9 +++++++++ rm.py | 7 +++++++ setup.py | 2 +- tests/test_rm.py | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 rm.py create mode 100755 tests/test_rm.py diff --git a/docs/index.rst b/docs/index.rst index 2da73c2..4605aaa 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -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 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) diff --git a/setup.py b/setup.py index 88b510d..b284717 100755 --- 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 index 0000000..631502c --- /dev/null +++ b/tests/test_rm.py @@ -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') -- 2.39.2