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

Commit2c19b98

Browse files
hroncokjgraham
authored andcommitted
Use Node.from_parent() constructor to support pytest 6
Add a wrapper not to break pytest 4 (needed for Python 2 support). ============================= test session starts ============================== platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini plugins: expect-1.1.0 collected 0 items / 1 error ==================================== ERRORS ==================================== ________________________ ERROR collecting test session _________________________ /usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__ return self._hookexec(self, self.get_hookimpls(), kwargs) /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec return self._inner_hookexec(hook, methods, kwargs) /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall( html5lib/tests/conftest.py:105: in pytest_collect_file return TokenizerFile(path, parent) /usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__ warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2) E pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent. E Seehttps://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.Fixes#505
1 parenta7c1887 commit2c19b98

File tree

5 files changed

+29
-20
lines changed

5 files changed

+29
-20
lines changed

‎html5lib/tests/conftest.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,19 @@ def pytest_collect_file(path, parent):
9999

100100
if_tree_constructionindir_and_parents:
101101
ifpath.ext==".dat":
102-
returnTreeConstructionFile(path,parent)
102+
returnTreeConstructionFile.from_parent(parent,fspath=path)
103103
elif_tokenizerindir_and_parents:
104104
ifpath.ext==".test":
105-
returnTokenizerFile(path,parent)
105+
returnTokenizerFile.from_parent(parent,fspath=path)
106106
elif_sanitizer_testdataindir_and_parents:
107107
ifpath.ext==".dat":
108-
returnSanitizerFile(path,parent)
108+
returnSanitizerFile.from_parent(parent,fspath=path)
109+
110+
111+
# Tiny wrapper to allow .from_parent constructors on older pytest for PY27
112+
ifnothasattr(pytest.Item.__base__,"from_parent"):
113+
@classmethod
114+
deffrom_parent(cls,parent,**kwargs):
115+
returncls(parent=parent,**kwargs)
116+
117+
pytest.Item.__base__.from_parent=from_parent

‎html5lib/tests/sanitizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def collect(self):
1313
withcodecs.open(str(self.fspath),"r",encoding="utf-8")asfp:
1414
tests=json.load(fp)
1515
fori,testinenumerate(tests):
16-
yieldSanitizerTest(str(i),self,test=test)
16+
yieldSanitizerTest.from_parent(self,name=str(i),test=test)
1717

1818

1919
classSanitizerTest(pytest.Item):

‎html5lib/tests/tokenizer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def collect(self):
192192
tests=json.load(fp)
193193
if'tests'intests:
194194
fori,testinenumerate(tests['tests']):
195-
yieldTokenizerTestCollector(str(i),self,testdata=test)
195+
yieldTokenizerTestCollector.from_parent(self,name=str(i),testdata=test)
196196

197197

198198
classTokenizerTestCollector(pytest.Collector):
@@ -207,10 +207,10 @@ def __init__(self, name, parent=None, config=None, session=None, testdata=None):
207207
defcollect(self):
208208
forinitialStateinself.testdata["initialStates"]:
209209
initialState=capitalize(initialState)
210-
item=TokenizerTest(initialState,
211-
self,
212-
self.testdata,
213-
initialState)
210+
item=TokenizerTest.from_parent(self,
211+
name=initialState,
212+
test=self.testdata,
213+
initialState=initialState)
214214
ifself.testdata["input"]isNone:
215215
item.add_marker(pytest.mark.skipif(True,reason="Relies on lone surrogates"))
216216
yielditem

‎html5lib/tests/tree_construction.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TreeConstructionFile(pytest.File):
2626
defcollect(self):
2727
tests=TestData(str(self.fspath),"data")
2828
fori,testinenumerate(tests):
29-
yieldTreeConstructionTest(str(i),self,testdata=test)
29+
yieldTreeConstructionTest.from_parent(self,name=str(i),testdata=test)
3030

3131

3232
classTreeConstructionTest(pytest.Collector):
@@ -48,11 +48,11 @@ def _getParserTests(self, treeName, treeAPIs):
4848
nodeid="%s::parser::namespaced"%treeName
4949
else:
5050
nodeid="%s::parser::void-namespace"%treeName
51-
item=ParserTest(nodeid,
52-
self,
53-
self.testdata,
54-
treeAPIs["builder"]iftreeAPIsisnotNoneelseNone,
55-
namespaceHTMLElements)
51+
item=ParserTest.from_parent(self,
52+
name=nodeid,
53+
test=self.testdata,
54+
treeClass=treeAPIs["builder"]iftreeAPIsisnotNoneelseNone,
55+
namespaceHTMLElements=namespaceHTMLElements)
5656
item.add_marker(getattr(pytest.mark,treeName))
5757
item.add_marker(pytest.mark.parser)
5858
ifnamespaceHTMLElements:
@@ -61,10 +61,10 @@ def _getParserTests(self, treeName, treeAPIs):
6161

6262
def_getTreeWalkerTests(self,treeName,treeAPIs):
6363
nodeid="%s::treewalker"%treeName
64-
item=TreeWalkerTest(nodeid,
65-
self,
66-
self.testdata,
67-
treeAPIs)
64+
item=TreeWalkerTest.from_parent(self,
65+
name=nodeid,
66+
test=self.testdata,
67+
treeAPIs=treeAPIs)
6868
item.add_marker(getattr(pytest.mark,treeName))
6969
item.add_marker(pytest.mark.treewalker)
7070
yielditem

‎requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
tox>=3.15.1,<4
44
flake8>=3.8.1,<3.9
55
pytest>=4.6.10,<5 ; python_version < '3'
6-
pytest>=5.4.2,<6 ; python_version >= '3'
6+
pytest>=5.4.2,<7 ; python_version >= '3'
77
coverage>=5.1,<6
88
pytest-expect>=1.1.0,<2
99
mock>=3.0.5,<4 ; python_version < '3.6'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp