mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
python: add concept and library tests
This commit is contained in:
@@ -164,6 +164,42 @@ class SqlExecutionTest extends InlineExpectationsTest {
|
||||
}
|
||||
}
|
||||
|
||||
class XPathConstructionTest extends InlineExpectationsTest {
|
||||
XPathConstructionTest() { this = "XPathConstructionTest" }
|
||||
|
||||
override string getARelevantTag() { result = "constructedXPath" }
|
||||
|
||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(location.getFile().getRelativePath()) and
|
||||
exists(XPathConstruction e, DataFlow::Node xpath |
|
||||
exists(location.getFile().getRelativePath()) and
|
||||
xpath = e.getXPath() and
|
||||
location = e.getLocation() and
|
||||
element = xpath.toString() and
|
||||
value = prettyNodeForInlineTest(xpath) and
|
||||
tag = "constructedXPath"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class XPathExecutionTest extends InlineExpectationsTest {
|
||||
XPathExecutionTest() { this = "XPathExecutionTest" }
|
||||
|
||||
override string getARelevantTag() { result = "getXPath" }
|
||||
|
||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(location.getFile().getRelativePath()) and
|
||||
exists(XPathExecution e, DataFlow::Node xpath |
|
||||
exists(location.getFile().getRelativePath()) and
|
||||
xpath = e.getXPath() and
|
||||
location = e.getLocation() and
|
||||
element = xpath.toString() and
|
||||
value = prettyNodeForInlineTest(xpath) and
|
||||
tag = "getXPath"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class EscapingTest extends InlineExpectationsTest {
|
||||
EscapingTest() { this = "EscapingTest" }
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
21
python/ql/test/library-tests/frameworks/lxml/test.py
Normal file
21
python/ql/test/library-tests/frameworks/lxml/test.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from lxml import etree
|
||||
from io import StringIO
|
||||
|
||||
def test_parse():
|
||||
tree = etree.parse(StringIO('<foo><bar></bar></foo>'))
|
||||
r = tree.xpath('/foo/bar') # $ getXPath='/foo/bar'
|
||||
|
||||
def test_XPath_class():
|
||||
root = etree.XML("<root><a>TEXT</a></root>")
|
||||
find_text = etree.XPath("path") # $ constructedXPath="path"
|
||||
text = find_text(root)[0]
|
||||
|
||||
def test_ETXpath_class():
|
||||
root = etree.XML("<root><a>TEXT</a></root>")
|
||||
find_text = etree.ETXPath("path") # $ constructedXPath="path"
|
||||
text = find_text(root)[0]
|
||||
|
||||
def test_XPathEvaluator_class():
|
||||
root = etree.XML("<root><a>TEXT</a></root>")
|
||||
search_root = etree.XPathEvaluator(root)
|
||||
text = search_root("path")[0] # $ MISSING: getXPath="path"
|
||||
Reference in New Issue
Block a user