Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add expected failures#174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletionshtml5lib/tests/expected-failures/tokenizer.dat
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
#data
<!DOCTYPE>

#data
<!DOCTYPE >

#data
<!DOCTYPE

#data
<!DOCTYPE


#data
<!DOCTYPE

#data
<!DOCTYPE

#data
<!DOCTYPE


#data
<!DOCTYPE

#data
<!DOCTYPE

#data
<!DOCTYPE

#data
<!DOCTYPE

#data
<!DOCTYPE

#data
<!DOCTYPE
59 changes: 59 additions & 0 deletionshtml5lib/tests/expected-failures/tree-construction.dat
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
#data
<html><ruby>a<rtc>b<rt>c<rb>d</ruby></html>

#data
<html><ruby>a<rb>b<rt></ruby></html>

#data
<!DOCTYPE html><body><svg attributename='' attributetype='' basefrequency='' baseprofile='' calcmode='' clippathunits='' contentscripttype='' contentstyletype='' diffuseconstant='' edgemode='' externalresourcesrequired='' filterres='' filterunits='' glyphref='' gradienttransform='' gradientunits='' kernelmatrix='' kernelunitlength='' keypoints='' keysplines='' keytimes='' lengthadjust='' limitingconeangle='' markerheight='' markerunits='' markerwidth='' maskcontentunits='' maskunits='' numoctaves='' pathlength='' patterncontentunits='' patterntransform='' patternunits='' pointsatx='' pointsaty='' pointsatz='' preservealpha='' preserveaspectratio='' primitiveunits='' refx='' refy='' repeatcount='' repeatdur='' requiredextensions='' requiredfeatures='' specularconstant='' specularexponent='' spreadmethod='' startoffset='' stddeviation='' stitchtiles='' surfacescale='' systemlanguage='' tablevalues='' targetx='' targety='' textlength='' viewbox='' viewtarget='' xchannelselector='' ychannelselector='' zoomandpan=''></svg>

#data
<html><ruby>a<rt>b<rb></ruby></html>

#data
<html><ruby>a<rt>b<rtc></ruby></html>

#data
<html><ruby><rtc><ruby>a<rb>b<rt></ruby></ruby></html>

#data
<!DOCTYPE html><body><command>A

#data
<html><ruby>a<rb>b<rp></ruby></html>

#data
<!DOCTYPE html><body><svg attributeName='' attributeType='' baseFrequency='' baseProfile='' calcMode='' clipPathUnits='' contentScriptType='' contentStyleType='' diffuseConstant='' edgeMode='' externalResourcesRequired='' filterRes='' filterUnits='' glyphRef='' gradientTransform='' gradientUnits='' kernelMatrix='' kernelUnitLength='' keyPoints='' keySplines='' keyTimes='' lengthAdjust='' limitingConeAngle='' markerHeight='' markerUnits='' markerWidth='' maskContentUnits='' maskUnits='' numOctaves='' pathLength='' patternContentUnits='' patternTransform='' patternUnits='' pointsAtX='' pointsAtY='' pointsAtZ='' preserveAlpha='' preserveAspectRatio='' primitiveUnits='' refX='' refY='' repeatCount='' repeatDur='' requiredExtensions='' requiredFeatures='' specularConstant='' specularExponent='' spreadMethod='' startOffset='' stdDeviation='' stitchTiles='' surfaceScale='' systemLanguage='' tableValues='' targetX='' targetY='' textLength='' viewBox='' viewTarget='' xChannelSelector='' yChannelSelector='' zoomAndPan=''></svg>

#data
<html><ruby>a<rtc>b<rtc></ruby></html>

#data
<!DOCTYPE html><frameset> te st

#data
<html><ruby>a<rp>b<rtc></ruby></html>

#data
<!DOCTYPE html><frameset></frameset> te st

#data
<html><ruby>a<rb>b<rb></ruby></html>

#data
<html><ruby>a<rtc>b<rp></ruby></html>

#data
<!DOCTYPE html><body><menuitem>A

#data
<!DOCTYPE html><BODY><SVG ATTRIBUTENAME='' ATTRIBUTETYPE='' BASEFREQUENCY='' BASEPROFILE='' CALCMODE='' CLIPPATHUNITS='' CONTENTSCRIPTTYPE='' CONTENTSTYLETYPE='' DIFFUSECONSTANT='' EDGEMODE='' EXTERNALRESOURCESREQUIRED='' FILTERRES='' FILTERUNITS='' GLYPHREF='' GRADIENTTRANSFORM='' GRADIENTUNITS='' KERNELMATRIX='' KERNELUNITLENGTH='' KEYPOINTS='' KEYSPLINES='' KEYTIMES='' LENGTHADJUST='' LIMITINGCONEANGLE='' MARKERHEIGHT='' MARKERUNITS='' MARKERWIDTH='' MASKCONTENTUNITS='' MASKUNITS='' NUMOCTAVES='' PATHLENGTH='' PATTERNCONTENTUNITS='' PATTERNTRANSFORM='' PATTERNUNITS='' POINTSATX='' POINTSATY='' POINTSATZ='' PRESERVEALPHA='' PRESERVEASPECTRATIO='' PRIMITIVEUNITS='' REFX='' REFY='' REPEATCOUNT='' REPEATDUR='' REQUIREDEXTENSIONS='' REQUIREDFEATURES='' SPECULARCONSTANT='' SPECULAREXPONENT='' SPREADMETHOD='' STARTOFFSET='' STDDEVIATION='' STITCHTILES='' SURFACESCALE='' SYSTEMLANGUAGE='' TABLEVALUES='' TARGETX='' TARGETY='' TEXTLENGTH='' VIEWBOX='' VIEWTARGET='' XCHANNELSELECTOR='' YCHANNELSELECTOR='' ZOOMANDPAN=''></SVG>

#data
<html><ruby>a<rp>b<rb></ruby></html>

#data
<html><ruby>a<rb>b<rtc></ruby></html>

#data
<html><ruby>a<rtc>b<rb></ruby></html>
18 changes: 17 additions & 1 deletionhtml5lib/tests/support.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@
import glob
import xml.sax.handler

from nose.plugins.skip import SkipTest

base_path = os.path.split(__file__)[0]

test_dir = os.path.join(base_path, 'testdata')
Expand DownExpand Up@@ -128,7 +130,7 @@ def convertData(data):
def errorMessage(input, expected, actual):
msg = ("Input:\n%s\nExpected:\n%s\nRecieved\n%s\n" %
(repr(input), repr(expected), repr(actual)))
if sys.version_info.major == 2:
if sys.version_info[0] == 2:
msg = msg.encode("ascii", "backslashreplace")
return msg

Expand DownExpand Up@@ -175,3 +177,17 @@ def processingInstruction(self, target, data):

def skippedEntity(self, name):
self.visited.append(('skippedEntity', name))


def xfail(test):
"""Expected fail decorator function"""
def t(*args, **kwargs):
try:
test(*args)
except SkipTest:
raise
except:
return
else:
assert False, "UNEXPECTED PASS"
return t
4 changes: 3 additions & 1 deletionhtml5lib/tests/test_encoding.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,8 @@
except AttributeError:
unittest.TestCase.assertEqual = unittest.TestCase.assertEquals

from nose.plugins.skip import SkipTest

from .support import get_data_files, TestData, test_dir, errorMessage
from html5lib import HTMLParser, inputstream

Expand DownExpand Up@@ -41,7 +43,7 @@ def runPreScanEncodingTest(data, encoding):

# Very crude way to ignore irrelevant tests
if len(data) > stream.numBytesMeta:
return
raise SkipTest()

assert encoding == stream.charEncoding[0], errorMessage(data, encoding, stream.charEncoding[0])

Expand Down
47 changes: 40 additions & 7 deletionshtml5lib/tests/test_parser.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,8 +8,11 @@

warnings.simplefilter("error")

from nose.plugins.skip import SkipTest

from .support import get_data_files
from .support import TestData, convert, convertExpected, treeTypes
from .support import xfail
from html5lib import html5parser, constants

# Run the parse error checks
Expand All@@ -26,7 +29,11 @@ def convertTreeDump(data):


def runParserTest(innerHTML, input, expected, errors, treeClass,
namespaceHTMLElements):
namespaceHTMLElements, scriptingDisabled):
if scriptingDisabled:
# We don't support the scripting disabled case!
raise SkipTest()

with warnings.catch_warnings(record=True) as caughtWarnings:
warnings.simplefilter("always")
p = html5parser.HTMLParser(tree=treeClass,
Expand All@@ -46,7 +53,7 @@ def runParserTest(innerHTML, input, expected, errors, treeClass,
if not issubclass(x.category, constants.DataLossWarning)]
assert len(otherWarnings) == 0, [(x.category, x.message) for x in otherWarnings]
if len(caughtWarnings):
return
raise SkipTest()

output = convertTreeDump(p.tree.testSerializer(document))

Expand All@@ -68,13 +75,27 @@ def runParserTest(innerHTML, input, expected, errors, treeClass,
"\nExpected errors (" + str(len(errors)) + "):\n" + "\n".join(errors),
"\nActual errors (" + str(len(p.errors)) + "):\n" + "\n".join(errStr)])
if checkParseErrors:
assert len(p.errors) == len(errors), errorMsg2
assert len(p.errors) == len(errors), errorMsg2


@xfail
def xfailRunParserTest(*args, **kwargs):
return runParserTest(*args, **kwargs)


def test_parser():
# Testin'
sys.stderr.write('Testing tree builders ' + " ".join(list(treeTypes.keys())) + "\n")
files = get_data_files('tree-construction')

# Get xfails
filename = os.path.join(os.path.split(__file__)[0],
"expected-failures",
"tree-construction.dat")
xfails = TestData(filename, "data")
xfails = frozenset([x["data"] for x in xfails])

# Get the tests
files = get_data_files('tree-construction')
for filename in files:
testName = os.path.basename(filename).replace(".dat", "")
if testName in ("template",):
Expand All@@ -84,13 +105,25 @@ def test_parser():

for index, test in enumerate(tests):
input, errors, innerHTML, expected = [test[key] for key in
('data', 'errors',
('data',
'errors',
'document-fragment',
'document')]

if errors:
errors = errors.split("\n")

assert not ("script-off" in test and "script-on" in test), \
("The following test has scripting enabled" +
"and disabled all at once: %s in %s" % (input, filename))

scriptingDisabled = "script-off" in test

for treeName, treeCls in treeTypes.items():
for namespaceHTMLElements in (True, False):
yield (runParserTest, innerHTML, input, expected, errors, treeCls,
namespaceHTMLElements)
if input in xfails:
testFunc = xfailRunParserTest
else:
testFunc = runParserTest
yield (testFunc, innerHTML, input, expected, errors, treeCls,
namespaceHTMLElements, scriptingDisabled)
27 changes: 23 additions & 4 deletionshtml5lib/tests/test_tokenizer.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,9 @@
import json
import warnings
import re
import os

from .support import get_data_files
from .support import get_data_files, TestData, xfail

from html5lib.tokenizer import HTMLTokenizer
from html5lib import constants
Expand DownExpand Up@@ -107,6 +108,7 @@ def tokensMatch(expectedTokens, receivedTokens, ignoreErrorOrder,
token.pop()

if not ignoreErrorOrder and not ignoreErrors:
expectedTokens = concatenateCharacterTokens(expectedTokens)
return expectedTokens == receivedTokens
else:
# Sort the tokens into two groups; non-parse errors and parse errors
Expand All@@ -119,6 +121,7 @@ def tokensMatch(expectedTokens, receivedTokens, ignoreErrorOrder,
else:
if not ignoreErrors:
tokens[tokenType][1].append(token)
tokens[tokenType][0] = concatenateCharacterTokens(tokens[tokenType][0])
return tokens["expected"] == tokens["received"]


Expand All@@ -143,13 +146,12 @@ def runTokenizerTest(test):
warnings.resetwarnings()
warnings.simplefilter("error")

expected =concatenateCharacterTokens(test['output'])
expected = test['output']
if 'lastStartTag' not in test:
test['lastStartTag'] = None
parser = TokenizerTestParser(test['initialState'],
test['lastStartTag'])
tokens = parser.parse(test['input'])
tokens = concatenateCharacterTokens(tokens)
received = normalizeTokens(tokens)
errorMsg = "\n".join(["\n\nInitial state:",
test['initialState'],
Expand All@@ -161,6 +163,11 @@ def runTokenizerTest(test):
assert tokensMatch(expected, received, ignoreErrorOrder, True), errorMsg


@xfail
def xfailRunTokenizerTest(*args, **kwargs):
return runTokenizerTest(*args, **kwargs)


def _doCapitalize(match):
return match.group(1).upper()

Expand All@@ -174,6 +181,14 @@ def capitalize(s):


def testTokenizer():
# Get xfails
filename = os.path.join(os.path.split(__file__)[0],
"expected-failures",
"tokenizer.dat")
xfails = TestData(filename, "data")
xfails = frozenset([x["data"] for x in xfails])

# Get tests
for filename in get_data_files('tokenizer', '*.test'):
with open(filename) as fp:
tests = json.load(fp)
Expand All@@ -185,4 +200,8 @@ def testTokenizer():
test = unescape(test)
for initialState in test["initialStates"]:
test["initialState"] = capitalize(initialState)
yield runTokenizerTest, test
if test['input'] in xfails:
testFunc = xfailRunTokenizerTest
else:
testFunc = runTokenizerTest
yield testFunc, test
Loading

[8]ページ先頭

©2009-2025 Movatter.jp