diff options
| author | Aur??lio A. Heckert <aurium@gmail.com> | 2009-04-13 18:38:09 +0000 |
|---|---|---|
| committer | aurium <aurium@users.sourceforge.net> | 2009-04-13 18:38:09 +0000 |
| commit | a95f7d43072285cfd5a32fcd6d1947eac19b6adc (patch) | |
| tree | 1f2ad7702a94581ff7c1d7f389cd1ebf8c8fc660 | |
| parent | run-all-extension-tests in make check (diff) | |
| download | inkscape-a95f7d43072285cfd5a32fcd6d1947eac19b6adc.tar.gz inkscape-a95f7d43072285cfd5a32fcd6d1947eac19b6adc.zip | |
a dummy help for extension unit test creation
(bzr r7703)
| -rwxr-xr-x | share/extensions/test/create_test_from_template.sh | 43 | ||||
| -rwxr-xr-x | share/extensions/test/foldablebox.test.py | 8 | ||||
| -rwxr-xr-x | share/extensions/test/run-all-extension-tests | 6 | ||||
| -rw-r--r-- | share/extensions/test/test_template.py.txt | 26 |
4 files changed, 77 insertions, 6 deletions
diff --git a/share/extensions/test/create_test_from_template.sh b/share/extensions/test/create_test_from_template.sh new file mode 100755 index 000000000..b2884dc19 --- /dev/null +++ b/share/extensions/test/create_test_from_template.sh @@ -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 diff --git a/share/extensions/test/foldablebox.test.py b/share/extensions/test/foldablebox.test.py index 814f10eae..63906c6a5 100755 --- a/share/extensions/test/foldablebox.test.py +++ b/share/extensions/test/foldablebox.test.py @@ -3,19 +3,19 @@ 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 b1ad95f79..00b127342 100755 --- a/share/extensions/test/run-all-extension-tests +++ b/share/extensions/test/run-all-extension-tests @@ -31,8 +31,10 @@ function run_py_test() { 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 new file mode 100644 index 000000000..9a570cd6a --- /dev/null +++ b/share/extensions/test/test_template.py.txt @@ -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() |
