|
1 | 1 | importos.path
|
2 | 2 |
|
| 3 | +importpkg_resources |
3 | 4 | importpytest
|
4 | 5 |
|
5 | 6 | from .tree_constructionimportTreeConstructionFile
|
6 | 7 | from .tokenizerimportTokenizerFile
|
7 | 8 | from .sanitizerimportSanitizerFile
|
8 | 9 |
|
9 | 10 | _dir=os.path.abspath(os.path.dirname(__file__))
|
| 11 | +_root=os.path.join(_dir,"..","..") |
10 | 12 | _testdata=os.path.join(_dir,"testdata")
|
11 | 13 | _tree_construction=os.path.join(_testdata,"tree-construction")
|
12 | 14 | _tokenizer=os.path.join(_testdata,"tokenizer")
|
|
15 | 17 |
|
16 | 18 | defpytest_configure(config):
|
17 | 19 | msgs= []
|
| 20 | + |
18 | 21 | ifnotos.path.exists(_testdata):
|
19 | 22 | msg="testdata not available! "
|
20 |
| -ifos.path.exists(os.path.join(_dir,"..","..",".git")): |
| 23 | +ifos.path.exists(os.path.join(_root,".git")): |
21 | 24 | msg+= ("Please run git submodule update --init --recursive "+
|
22 | 25 | "and then run tests again.")
|
23 | 26 | else:
|
24 | 27 | msg+= ("The testdata doesn't appear to be included with this package, "+
|
25 | 28 | "so finding the right version will be hard. :(")
|
26 | 29 | 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 | + |
27 | 67 | ifmsgs:
|
28 | 68 | pytest.exit("\n".join(msgs))
|
29 | 69 |
|
|