mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Python: Add copy of extractor tests
These get to live next to the existing library and query tests, and are run as part of both the Python 2 and Python 3 language tests.
This commit is contained in:
8
python/ql/test/extractor-tests/syntax_error/eof.py
Normal file
8
python/ql/test/extractor-tests/syntax_error/eof.py
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
import unittest
|
||||
|
||||
#This should cause a syntax error at the end of line 8
|
||||
|
||||
class TestBase(unittest.TestCase):
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#Illegal use of rhs expression of lhs
|
||||
[x for a in b] = y
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
#This parses, but is illegal.
|
||||
"hello" = "world"
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
a if cond else b = 1
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
def foo(seq):
|
||||
for var in seq:
|
||||
body
|
||||
illegal-dedent
|
||||
@@ -0,0 +1,4 @@
|
||||
def foo(seq):
|
||||
for var in seq:
|
||||
body
|
||||
illegal-dedent
|
||||
1
python/ql/test/extractor-tests/syntax_error/options
Normal file
1
python/ql/test/extractor-tests/syntax_error/options
Normal file
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: --max-import-depth=0
|
||||
@@ -0,0 +1,3 @@
|
||||
| illegal_context2.py | Syntax Error | 3 | 1 |
|
||||
| illegal_context.py | Syntax Error | 2 | 1 |
|
||||
| illegal_if.py | Syntax Error | 7 | 1 |
|
||||
5
python/ql/test/extractor-tests/syntax_error/test.ql
Normal file
5
python/ql/test/extractor-tests/syntax_error/test.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import python
|
||||
|
||||
from SyntaxError s, string fp, int line, int col
|
||||
where s.hasLocationInfo(fp, line, col, _, _)
|
||||
select fp, s.toString(), line, col
|
||||
Reference in New Issue
Block a user