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

Use Node.from_parent() constructor to support pytest 6#506

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

Merged
jgraham merged 1 commit intohtml5lib:masterfromhroncok:pytest6
Aug 10, 2020
Merged
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
15 changes: 12 additions & 3 deletionshtml5lib/tests/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,10 +99,19 @@ def pytest_collect_file(path, parent):

if_tree_constructionindir_and_parents:
ifpath.ext==".dat":
returnTreeConstructionFile(path,parent)
returnTreeConstructionFile.from_parent(parent,fspath=path)
elif_tokenizerindir_and_parents:
ifpath.ext==".test":
returnTokenizerFile(path,parent)
returnTokenizerFile.from_parent(parent,fspath=path)
elif_sanitizer_testdataindir_and_parents:
ifpath.ext==".dat":
returnSanitizerFile(path,parent)
returnSanitizerFile.from_parent(parent,fspath=path)


# Tiny wrapper to allow .from_parent constructors on older pytest for PY27
ifnothasattr(pytest.Item.__base__,"from_parent"):
@classmethod
deffrom_parent(cls,parent,**kwargs):
returncls(parent=parent,**kwargs)

pytest.Item.__base__.from_parent=from_parent
2 changes: 1 addition & 1 deletionhtml5lib/tests/sanitizer.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@ def collect(self):
withcodecs.open(str(self.fspath),"r",encoding="utf-8")asfp:
tests=json.load(fp)
fori,testinenumerate(tests):
yieldSanitizerTest(str(i),self,test=test)
yieldSanitizerTest.from_parent(self,name=str(i),test=test)


classSanitizerTest(pytest.Item):
Expand Down
10 changes: 5 additions & 5 deletionshtml5lib/tests/tokenizer.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -192,7 +192,7 @@ def collect(self):
tests=json.load(fp)
if'tests'intests:
fori,testinenumerate(tests['tests']):
yieldTokenizerTestCollector(str(i),self,testdata=test)
yieldTokenizerTestCollector.from_parent(self,name=str(i),testdata=test)


classTokenizerTestCollector(pytest.Collector):
Expand All@@ -207,10 +207,10 @@ def __init__(self, name, parent=None, config=None, session=None, testdata=None):
defcollect(self):
forinitialStateinself.testdata["initialStates"]:
initialState=capitalize(initialState)
item=TokenizerTest(initialState,
self,
self.testdata,
initialState)
item=TokenizerTest.from_parent(self,
name=initialState,
test=self.testdata,
initialState=initialState)
ifself.testdata["input"]isNone:
item.add_marker(pytest.mark.skipif(True,reason="Relies on lone surrogates"))
yielditem
Expand Down
20 changes: 10 additions & 10 deletionshtml5lib/tests/tree_construction.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,7 +26,7 @@ class TreeConstructionFile(pytest.File):
defcollect(self):
tests=TestData(str(self.fspath),"data")
fori,testinenumerate(tests):
yieldTreeConstructionTest(str(i),self,testdata=test)
yieldTreeConstructionTest.from_parent(self,name=str(i),testdata=test)


classTreeConstructionTest(pytest.Collector):
Expand All@@ -48,11 +48,11 @@ def _getParserTests(self, treeName, treeAPIs):
nodeid="%s::parser::namespaced"%treeName
else:
nodeid="%s::parser::void-namespace"%treeName
item=ParserTest(nodeid,
self,
self.testdata,
treeAPIs["builder"]iftreeAPIsisnotNoneelseNone,
namespaceHTMLElements)
item=ParserTest.from_parent(self,
name=nodeid,
test=self.testdata,
treeClass=treeAPIs["builder"]iftreeAPIsisnotNoneelseNone,
namespaceHTMLElements=namespaceHTMLElements)
item.add_marker(getattr(pytest.mark,treeName))
item.add_marker(pytest.mark.parser)
ifnamespaceHTMLElements:
Expand All@@ -61,10 +61,10 @@ def _getParserTests(self, treeName, treeAPIs):

def_getTreeWalkerTests(self,treeName,treeAPIs):
nodeid="%s::treewalker"%treeName
item=TreeWalkerTest(nodeid,
self,
self.testdata,
treeAPIs)
item=TreeWalkerTest.from_parent(self,
name=nodeid,
test=self.testdata,
treeAPIs=treeAPIs)
item.add_marker(getattr(pytest.mark,treeName))
item.add_marker(pytest.mark.treewalker)
yielditem
Expand Down
2 changes: 1 addition & 1 deletionrequirements-test.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@
tox>=3.15.1,<4
flake8>=3.8.1,<3.9
pytest>=4.6.10,<5 ; python_version < '3'
pytest>=5.4.2,<6 ; python_version >= '3'
pytest>=5.4.2,<7 ; python_version >= '3'
coverage>=5.1,<6
pytest-expect>=1.1.0,<2
mock>=3.0.5,<4 ; python_version < '3.6'
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp