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

Commita6550ac

Browse files
committed
Fix#237: fail if --update-xfail is used in wrong environment
1 parent2b73979 commita6550ac

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

‎html5lib/tests/conftest.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
importos.path
22

3+
importpkg_resources
34
importpytest
45

56
from .tree_constructionimportTreeConstructionFile
67
from .tokenizerimportTokenizerFile
78
from .sanitizerimportSanitizerFile
89

910
_dir=os.path.abspath(os.path.dirname(__file__))
11+
_root=os.path.join(_dir,"..","..")
1012
_testdata=os.path.join(_dir,"testdata")
1113
_tree_construction=os.path.join(_testdata,"tree-construction")
1214
_tokenizer=os.path.join(_testdata,"tokenizer")
@@ -15,15 +17,53 @@
1517

1618
defpytest_configure(config):
1719
msgs= []
20+
1821
ifnotos.path.exists(_testdata):
1922
msg="testdata not available! "
20-
ifos.path.exists(os.path.join(_dir,"..","..",".git")):
23+
ifos.path.exists(os.path.join(_root,".git")):
2124
msg+= ("Please run git submodule update --init --recursive "+
2225
"and then run tests again.")
2326
else:
2427
msg+= ("The testdata doesn't appear to be included with this package, "+
2528
"so finding the right version will be hard. :(")
2629
msgs.append(msg)
30+
31+
ifconfig.option.update_xfail:
32+
# Check for optional requirements
33+
req_file=os.path.join(_root,"requirements-optional.txt")
34+
ifos.path.exists(req_file):
35+
withopen(req_file,"r")asfp:
36+
forlineinfp:
37+
if (line.strip()and
38+
not (line.startswith("-r")or
39+
line.startswith("#"))):
40+
if";"inline:
41+
spec,marker=line.strip().split(";",1)
42+
else:
43+
spec,marker=line.strip(),None
44+
req=pkg_resources.Requirement.parse(spec)
45+
ifmarkerandnotpkg_resources.evaluate_marker(marker):
46+
msgs.append("%s not available in this environment"%spec)
47+
else:
48+
try:
49+
installed=pkg_resources.working_set.find(req)
50+
exceptpkg_resources.VersionConflict:
51+
msgs.append("Outdated version of %s installed, need %s"% (req.name,spec))
52+
else:
53+
ifnotinstalled:
54+
msgs.append("Need %s"%spec)
55+
56+
# Check cElementTree
57+
importxml.etree.ElementTreeasElementTree
58+
59+
try:
60+
importxml.etree.cElementTreeascElementTree
61+
exceptImportError:
62+
msgs.append("cElementTree unable to be imported")
63+
else:
64+
ifcElementTree.ElementisElementTree.Element:
65+
msgs.append("cElementTree is just an alias for ElementTree")
66+
2767
ifmsgs:
2868
pytest.exit("\n".join(msgs))
2969

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp