From 96bc9c67fc993dc918ea80c208096b9523a68f6f Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 6 Oct 2017 20:16:34 +0300 Subject: [PATCH] Refactor(tests): Exit with "name not found in PATH" in find_in_path --- tests/ppu_tu.py | 2 ++ tests/test_cmp.py | 3 --- tests/test_remove_old_files.py | 2 -- tests/test_rm.py | 3 --- tests/test_which.py | 3 --- 5 files changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/ppu_tu.py b/tests/ppu_tu.py index 563774a..1ce2b64 100644 --- a/tests/ppu_tu.py +++ b/tests/ppu_tu.py @@ -3,6 +3,7 @@ import os import shutil +import sys from tempfile import mkdtemp @@ -23,6 +24,7 @@ def find_in_path(name): test_prog_path = os.path.join(path, name) if os.path.exists(test_prog_path): return test_prog_path + sys.exit("Cannot find %s in %s" % (name, os.environ["PATH"])) def create_files(files, subdirectory=None): diff --git a/tests/test_cmp.py b/tests/test_cmp.py index 24dfd5f..efdd43a 100755 --- a/tests/test_cmp.py +++ b/tests/test_cmp.py @@ -1,14 +1,11 @@ #! /usr/bin/env python -import os import subprocess import sys from ppu_tu import setup, teardown, find_in_path # noqa test_prog_path = find_in_path('cmp.py') -if not test_prog_path: - sys.exit("Cannot find cmp.py in %s" % os.environ["PATH"]) def create_file(name, content): diff --git a/tests/test_remove_old_files.py b/tests/test_remove_old_files.py index 80c91e4..dce091d 100755 --- a/tests/test_remove_old_files.py +++ b/tests/test_remove_old_files.py @@ -9,8 +9,6 @@ from ppu_tu import create_files, assert_files_exist, assert_files_not_exist test_prog_path = find_in_path('remove-old-files.py') -if not test_prog_path: - sys.exit("Cannot find remove-old-files.py in %s" % os.environ["PATH"]) old_time = time() - 1000 * 24 * 3600 # 1000 days ago diff --git a/tests/test_rm.py b/tests/test_rm.py index f7550da..b9ad1b8 100755 --- a/tests/test_rm.py +++ b/tests/test_rm.py @@ -1,6 +1,5 @@ #! /usr/bin/env python -import os import subprocess import sys from ppu_tu import setup, teardown, find_in_path # noqa @@ -8,8 +7,6 @@ from ppu_tu import create_files, assert_files_exist, assert_files_not_exist 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(): diff --git a/tests/test_which.py b/tests/test_which.py index b65a832..3c5f855 100755 --- a/tests/test_which.py +++ b/tests/test_which.py @@ -1,14 +1,11 @@ #! /usr/bin/env python -import os import subprocess import sys from ppu_tu import setup, teardown, find_in_path # noqa test_prog_path = find_in_path('which.py') -if not test_prog_path: - sys.exit("Cannot find which.py in %s" % os.environ["PATH"]) def test_which(): -- 2.39.5