Commits

Anonymous committed b675f4b

Add hachoir-regex/test_doc.py to trunk/test_code.sh (and remove old hachoir-regex/hachoir_regex/testall.py)

Comments (0)

Files changed (4)

hachoir-regex/hachoir_regex/testall.py

-#!/usr/bin/env python
-import doctest
-import sys
-
-def testmod(modname):
-    print "--- test module %s ---" % modname
-    mod = __import__(modname)
-    failure, nb_test = doctest.testmod(mod)
-    if failure:
-        sys.exit(1)
-
-def testdoc(filename):
-    print "--- test documentation %s ---" % filename
-    failure, nb_test = doctest.testfile(
-        filename, optionflags=doctest.ELLIPSIS)
-    if failure:
-        sys.exit(1)
-
-def main():
-    testmod("regex")
-    testmod("parser")
-    testdoc("doc.rst")
-
-if __name__ == "__main__":
-    main()
-

hachoir-regex/regex.rst

 Create regex with string
 ------------------------
 
->>> from hachoir_core.regex import parse
+>>> from hachoir_regex import parse
 >>> parse('')
 <RegexEmpty ''>
 >>> parse('abc')
 Create regex with the API
 -------------------------
 
->>> from hachoir_core.regex import createString, createRange
+>>> from hachoir_regex import createString, createRange
 >>> createString('')
 <RegexEmpty ''>
 >>> createString('abc')
 
 Convert to string:
 
->>> from hachoir_core.regex import createRange, createString
+>>> from hachoir_regex import createRange, createString
 >>> str(createString('abc'))
 'abc'
 >>> repr(createString('abc'))
 
 Merge ranges:
 
->>> from hachoir_core.regex import createRange
+>>> from hachoir_regex import createRange
 >>> regex = createString("1") | createString("3"); regex
 <RegexRange '[13]'>
 >>> regex = regex | createRange("2"); regex
 Use addString() and addRegex() to add your patterns and then don't forget
 to call commit().
 
-    >>> from hachoir_core.regex import PatternMatching
+    >>> from hachoir_regex import PatternMatching
     >>> p = PatternMatching()
     >>> p.addString("a")
     >>> p.addString("b")

hachoir-regex/regression.rst

 Factorisation of (a{n,p}){x,y}:
 -------------------------------
 
->>> from hachoir_core.regex import parse
+>>> from hachoir_regex import parse
 >>> parse("(a{2,3}){4,5}")
 <RegexRepeat 'a{8,15}'>
 >>> parse("(a{2,}){3,4}")
 Regex regression (b)
 ====================
 
->>> from hachoir_core.regex import parse
+>>> from hachoir_regex import parse
 >>> parse("(M(SCF|Thd)|B(MP4|Zh))")
 <RegexOr '(M(SCF|Thd)|B(MP4|Zh))'>
 >>> parse("(FWS1|CWS1|FWS2|CWS2)")
 
 echo "=== hachoir-metadata: testcase ==="
 $PYTHON $ROOT/hachoir-metadata/run_testcase.py $TESTCASE
+
+echo "=== hachoir-regex: tests ==="
+$PYTHON $ROOT/hachoir-regex/test_doc.py