mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-31 09:49:23 +03:00
python/tests/reader2: always exit(1) if a test fails
Batch up the errors in the first parse tests and ensure that the last tests exit with an error if they fail. Also remove an unused import.
This commit is contained in:
@ -6,7 +6,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
import string
|
|
||||||
import libxml2
|
import libxml2
|
||||||
try:
|
try:
|
||||||
import StringIO
|
import StringIO
|
||||||
@ -129,6 +128,7 @@ expect_parsing_error = ["{}{}.xml".format(dir_prefix, f) for f in parsing_error_
|
|||||||
valid_files = glob.glob(dir_prefix + "*.x*")
|
valid_files = glob.glob(dir_prefix + "*.x*")
|
||||||
assert valid_files, "found no valid files in '{}'".format(dir_prefix)
|
assert valid_files, "found no valid files in '{}'".format(dir_prefix)
|
||||||
valid_files.sort()
|
valid_files.sort()
|
||||||
|
failures = 0
|
||||||
for file in valid_files:
|
for file in valid_files:
|
||||||
err = ""
|
err = ""
|
||||||
reader = libxml2.newTextReaderFilename(file)
|
reader = libxml2.newTextReaderFilename(file)
|
||||||
@ -142,9 +142,15 @@ for file in valid_files:
|
|||||||
#sys.exit(1)
|
#sys.exit(1)
|
||||||
if (err):
|
if (err):
|
||||||
if not(file in expect and err == expect[file]):
|
if not(file in expect and err == expect[file]):
|
||||||
|
failures += 1
|
||||||
print("Error: ", err)
|
print("Error: ", err)
|
||||||
if file in expect:
|
if file in expect:
|
||||||
print("Expected: ", expect[file])
|
print("Expected: ", expect[file])
|
||||||
|
|
||||||
|
if failures:
|
||||||
|
print("Failed %d tests" % failures)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
#
|
#
|
||||||
# another separate test based on Stephane Bidoul one
|
# another separate test based on Stephane Bidoul one
|
||||||
#
|
#
|
||||||
@ -337,9 +343,11 @@ while reader.Read() == 1:
|
|||||||
if res != expect:
|
if res != expect:
|
||||||
print("test5 failed: unexpected output")
|
print("test5 failed: unexpected output")
|
||||||
print(res)
|
print(res)
|
||||||
|
sys.exit(1)
|
||||||
if err != "":
|
if err != "":
|
||||||
print("test5 failed: validation error found")
|
print("test5 failed: validation error found")
|
||||||
print(err)
|
print(err)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
#
|
#
|
||||||
# cleanup
|
# cleanup
|
||||||
|
Reference in New Issue
Block a user