summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2ebfcf7)
raw | patch | inline | side by side (parent: 2ebfcf7)
author | aurium <aurium@users.sourceforge.net> | |
Mon, 13 Apr 2009 18:38:09 +0000 (18:38 +0000) | ||
committer | aurium <aurium@users.sourceforge.net> | |
Mon, 13 Apr 2009 18:38:09 +0000 (18:38 +0000) |
share/extensions/test/create_test_from_template.sh | [new file with mode: 0755] | patch | blob |
share/extensions/test/foldablebox.test.py | patch | blob | history | |
share/extensions/test/run-all-extension-tests | patch | blob | history | |
share/extensions/test/test_template.py.txt | [new file with mode: 0644] | patch | blob |
diff --git a/share/extensions/test/create_test_from_template.sh b/share/extensions/test/create_test_from_template.sh
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+exFile="$1"
+
+if test -z "$exFile" -o \! -f "$exFile"; then
+ echo "
+ This script is a dummy help for the creation of a
+ extension unity test file.
+
+ Usage:
+ $( basename "$0" ) ../extenion.py
+ "
+ exit 0
+fi
+
+module=$( echo "$exFile" | sed -r 's/^.*\/([^\/.]+)..*$/\1/' )
+
+if grep -q '^\s*class .*[( ]inkex.Effect[ )]' $exFile; then
+ pyClass=$( grep '^\s*class .*[( ]inkex.Effect[ )]' $exFile | sed -r 's/^\s*class\s+([^ ]+)\s*\(.*$/\1/' )
+else
+ echo "
+ ERROR: Incompatible Format or Inheritance.
+ At this time this script only knows how to make unit tests
+ for Python effects based on inkex.Effect.
+ "
+ exit 1
+fi
+
+exFileRE="$( echo "$exFile" | sed -r 's/\./\\./g; s/\//\\\//g' )"
+
+num=0
+testFile="$module.test.py"
+while test -e "$testFile"; do
+ let num++
+ testFile="$module.test$num.py"
+done
+
+echo ">> Creating $testFile"
+
+sed -r "s/%MODULE%/$module/g; s/%CLASS%/$pyClass/g; s/%FILE%/$exFileRE/g" \
+ test_template.py.txt > "$testFile"
+
+chmod +x "$testFile"
\ No newline at end of file
index 814f10eaed476d1da1f86f36ae0ee1cb6711e7fb..63906c6a5c3301a11d0d09498b34cf5535546da1 100755 (executable)
import sys
sys.path.append('..') # this line allows to import the extension code
-import unittest, calendar
+import unittest
from foldablebox import *
class FoldableBoxArguments(unittest.TestCase):
#def setUp(self):
- def test_default_names_list(self):
+ def test_basic_box_elements(self):
args = [ 'minimal-blank.svg' ]
e = FoldableBox()
e.affect( args, False )
- self.assertEqual( e.options.width, 10.0 )
+ self.assertEqual( e.box.tag, 'g', 'The box group must be created.' )
+ self.assertEqual( len( e.box.getchildren() ), 13, 'The box group must have 13 childs.' )
if __name__ == '__main__':
unittest.main()
-
diff --git a/share/extensions/test/run-all-extension-tests b/share/extensions/test/run-all-extension-tests
index b1ad95f7928e6d79160e0a997982e8b02a1e579e..00b1273424f3f122af5b1298ce0005af807bec07 100755 (executable)
fi
}
-run_py_test svgcalendar
-run_py_test foldablebox
+ls -1 *.test.py |
+while read testFile; do
+ run_py_test $( echo $testFile | sed -r 's/^([^.]+)..*$/\1/' )
+done
echo ""
if $has_py_coverage; then
diff --git a/share/extensions/test/test_template.py.txt b/share/extensions/test/test_template.py.txt
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+# This is only the automatic generated test file for %FILE%
+# This must be filled with real tests and this commentary
+# must be cleared.
+# If you want to help, read the python unittest documentation:
+# http://docs.python.org/library/unittest.html
+
+import sys
+sys.path.append('..') # this line allows to import the extension code
+
+import unittest
+from %MODULE% import *
+
+class %CLASS%BasicTest(unittest.TestCase):
+
+ #def setUp(self):
+
+ def test_run_without_parameters(self):
+ args = [ 'minimal-blank.svg' ]
+ e = %CLASS%()
+ e.affect( args, False )
+ #self.assertEqual( e.something, 'some value', 'A commentary about that.' )
+
+if __name__ == '__main__':
+ unittest.main()