Forráskód Böngészése

Added unit test framework and empty Cache class file.

Taddeus Kroes 14 éve
szülő
commit
f39773c776
7 módosított fájl, 68 hozzáadás és 0 törlés
  1. 3 0
      .gitignore
  2. 53 0
      Makefile
  3. 0 0
      src/__init__.py
  4. 2 0
      src/cache.py
  5. 5 0
      test.py
  6. 0 0
      tests/__init__.py
  7. 5 0
      tests/test_cache.py

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+*.swp
+*~
+*.pyc

+ 53 - 0
Makefile

@@ -0,0 +1,53 @@
+OMIT=/usr/share/pyshared/*,/usr/local/lib/python*,*__init__.py,test*
+COVERAGE_OUTPUT_DIR=coverage
+TESTS=`find tests -name test_\*.py`
+
+# Find python coverage version
+ifeq ($(findstring python-coverage,$(wildcard /usr/bin/*)), python-coverage)
+COVERAGE=/usr/bin/python-coverage
+else
+COVERAGE=`which coverage`
+endif
+
+all:
+
+# Unit tests
+test:
+	@for t in ${TESTS}; do \
+		python test.py $$t; \
+	done
+
+# Cleanup
+clean:
+	rm -rf .coverage ${COVERAGE_OUTPUT_DIR}
+
+distclean: clean
+	rm -rf `find -name \*.pyc`
+
+# Code coverage (differs between versions)
+coverage: .coverage
+
+ifeq ($(findstring python-coverage,$(wildcard /usr/bin/*)), python-coverage)
+.coverage:
+	@${COVERAGE} erase
+	@rm -f ${COVERAGE_OUTPUT_DIR}/*
+	@mkdir -p ${COVERAGE_OUTPUT_DIR} 2>/dev/null || true
+	@for t in ${TESTS}; do \
+		${COVERAGE} -x test.py $$t; \
+		${COVERAGE} combine; \
+	done
+	@${COVERAGE} html --omit=${OMIT} -d ${COVERAGE_OUTPUT_DIR}
+	@rm $@
+	@echo "Coverage report created in ${COVERAGE_OUTPUT_DIR}/index.html"
+else
+.coverage:
+	@mkdir -p ${COVERAGE_OUTPUT_DIR} 2>/dev/null || true
+	@${COVERAGE} erase
+	@for t in ${TESTS}; do \
+		${COVERAGE} --omit ${OMIT} -x test.py $$t; \
+		${COVERAGE} --omit ${OMIT} -c; \
+	done
+	@${COVERAGE} html --omit ${OMIT} --dir ${COVERAGE_OUTPUT_DIR}
+	@rm $@
+	@echo "Coverage report created in ${COVERAGE_OUTPUT_DIR}/index.html"
+endif

+ 0 - 0
src/__init__.py


+ 2 - 0
src/cache.py

@@ -0,0 +1,2 @@
+class Cache:
+    pass

+ 5 - 0
test.py

@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+from testrunner import main
+import sys
+
+main(sys.argv[1:])

+ 0 - 0
tests/__init__.py


+ 5 - 0
tests/test_cache.py

@@ -0,0 +1,5 @@
+import unittest
+
+
+class TestCache(unittest.TestCase):
+    pass