]> git.phdru.name Git - ppu.git/commitdiff
Refactor(tests): Exit with "name not found in PATH" in find_in_path
authorOleg Broytman <phd@phdru.name>
Fri, 6 Oct 2017 17:16:34 +0000 (20:16 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 6 Oct 2017 17:20:51 +0000 (20:20 +0300)
tests/ppu_tu.py
tests/test_cmp.py
tests/test_remove_old_files.py
tests/test_rm.py
tests/test_which.py

index 563774a953336151da78cf9f4bc8b10440f39410..1ce2b64fd040dc196dbf051c07c7156bdec879d7 100644 (file)
@@ -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):
index 24dfd5fc8665f91c5feb424b6a36e15be260d4a7..efdd43ae6dc24af4a4200f815f074bd1b8ead49c 100755 (executable)
@@ -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):
index 80c91e4e05e9fb375249a16cdbf84ef06264beb2..dce091d7334b3fe3a0bc261faeeec4c70bfffd7a 100755 (executable)
@@ -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
index f7550da394be47acfbc6cee5f61e6e335ab83c99..b9ad1b8b2a9ebeeba0cf124cb48c92c54d0e7d44 100755 (executable)
@@ -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():
index b65a832eb57c1eb380789435a456e8550163a417..3c5f85583a83931e3a8011885e8d3ffbcbcc4996 100755 (executable)
@@ -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():