Commits

Guido Draheim committed 158c7bf

make test_01 and make testlist

Comments (0)

Files changed (2)

 check:
 	PYTHONPATH=src \
 	python src/tests/computer_test.py -vv $(CHECK)
-test_%:
-	@ func1=`grep "def $@" src/tests/computer_test.py \
+test_%:        # run a single unittest by giving the function name
+	@ for filename in src/tests/*_test.py ; do : \
+	;  class=`basename $$filename .py` \
+	;  func1=`grep "def $@" $$filename \
 	    | sed -e "s/.*def  *//" -e "s/[(].*//" -e q` \
-	; func2=`grep "def $@" src/tests/computer_tests.py \
-	    | sed -e "s/.*def  *//" -e "s/[(].*//" -e q` \
-	; if test -n "$$func1" \
-	; then echo $(MAKE) check CHECK=DvbComputerTests.$$func1 \
-	;           $(MAKE) check CHECK=DvbComputerTests.$$func1 \
-	; elif test -n "$$func2" \
-	; then echo $(MAKE) checks CHECK=DvbGeneratedTests.$$func2 \
-	;           $(MAKE) checks CHECK=DvbGeneratedTests.$$func2 \
-	; else echo "unknown $@"; exit 1 \
+	;  test -n "$$func1" && break \
+	; done \
+	; if test -n "$check" ; then : \
+	;   echo "PYTHONPATH=src  \\" \
+	;   echo "python $$filename $$class.$$func1" \
+	;   echo "" \
+	;         PYTHONPATH=src \
+	          python $$filename "$$class.$$func1" \
+	; else : \
+	    echo "not found $@ in src/tests"; exit 1 \
 	; fi
+testlist:      # show available unittest function names (for test_%)
+	@ for filename in src/tests/*_test.py ; do : \
+	;  class=`basename $$filename .py` \
+	;  echo "$$class:" \
+	;  cat $$filename \
+	     | sed -e "/^ *def test_/!d" -e "s/.*def  *//" -e "s/[(].*//" \
+	           -e "s/^/  /" \
+	; done 
+help:          # shows this help
+	@ cat $(MAKEFILE_LIST) | sed -e "/^[.a-z][-a-z0-9 _%]*:/!d" -e "s|: |:        |"
 
 genchecks:
 	PYTHONPATH=src \

src/tests/computer_test.py

 Locale = collections.namedtuple("Locale",["language"])
 Request = collections.namedtuple("Request",["locale"])
 
-class DvbComputerTests(unittest.TestCase):
+class computer_test(unittest.TestCase):
     env = None
     logg = _logg
     def setUp(self):
         prefix = True
         postfix = False
         for line in open(__file__):
-            line = line.replace("DvbComputerTests", "DvbGeneratedTests")
+            line = line.replace("computer_test", "computer_tests")
             if prefix:
                 f.write(line)
                 if ("END %s" % "PREFIX") in line: