From 872c2047e5eddb1ffe684807f78a5ef5d4b63cc8 Mon Sep 17 00:00:00 2001 From: Frank Scherrer Date: Tue, 28 Aug 2018 14:52:17 +0200 Subject: [PATCH] add test for util.which * and make runtests.sh dash-compatible for debian-like OS --- runtests.sh | 2 +- tests/test_util.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/runtests.sh b/runtests.sh index 3ae7ddb..549eb4a 100755 --- a/runtests.sh +++ b/runtests.sh @@ -3,7 +3,7 @@ echo "testing with $(python2 -V 2>&1)" python2 $(which nosetests) -v --with-coverage --cover-erase tests/ -if [ $? == 0 ]; then +if test $? -eq 0 ; then echo echo "testing with $(python3 -V 2>&1)" diff --git a/tests/test_util.py b/tests/test_util.py index 1988756..64c320f 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -2,6 +2,7 @@ import mock import unittest +import re import tests.mocks as mocks @@ -53,4 +54,12 @@ class TestUtil(unittest.TestCase): with self.assertRaises(RuntimeError): execute(self.some_command_with_args) + def test_which(self): + program = "iwgetid" + self.assertTrue( + which(program) is None or + re.search('/(' + program + ')$', which(program)) + ) + + # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4