Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7fdfd3

Browse files
committed
Python: Move subprocess.call so super-class detection works
This is a temporary fix! Added minimal working example (MWE) as a regression, so it's easier to fix the real problem. only Python 3 is facing the problem -- and without --max-import-depth=1 the test times out at 10 minutes :O
1 parent d7b803a commit e7fdfd3

9 files changed

Lines changed: 48 additions & 3 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| mwe_failure.py:7:1:7:23 | class MyTest | <MISSING BASE TYPE> |
2+
| mwe_failure_2.py:7:1:7:23 | class MyTest | <MISSING BASE TYPE> |
3+
| mwe_success.py:7:1:7:23 | class MyTest | class TestCase |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import python
2+
3+
// as used in semmle.python.filters.Tests
4+
5+
from ClassValue c, string base
6+
where
7+
c.getScope().getLocation().getFile().getShortName().matches("mwe%.py") and
8+
c.getName() = "MyTest" and
9+
if exists(c.getABaseType()) then base = c.getABaseType().toString() else base = "<MISSING BASE TYPE>"
10+
select c, base
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import subprocess
2+
assert subprocess.call(['run-backup']) == 0
3+
4+
class TestCase:
5+
pass
6+
7+
class MyTest(TestCase):
8+
pass
9+
10+
# found by /home/rasmus/code/ql/python/ql/test/query-tests/Statements/asserts/AssertLiteralConstant.qlref
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import subprocess
2+
assert subprocess.call(['run-backup'])
3+
4+
class TestCase:
5+
pass
6+
7+
class MyTest(TestCase):
8+
pass
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import subprocess
2+
subprocess.call(['run-backup'])
3+
4+
class TestCase:
5+
pass
6+
7+
class MyTest(TestCase):
8+
pass
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: --lang=3 --max-import-depth=1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
| assert.py:5:5:5:20 | Assert | This 'assert' statement contains $@ which may have side effects. | assert.py:5:13:5:19 | Yield | an expression |
22
| assert.py:8:5:8:22 | Assert | This 'assert' statement contains $@ which may have side effects. | assert.py:8:12:8:22 | Attribute() | an expression |
3-
| assert.py:20:1:20:43 | Assert | This 'assert' statement contains $@ which may have side effects. | assert.py:20:8:20:38 | Attribute() | an expression |
3+
| side_effect.py:5:1:5:43 | Assert | This 'assert' statement contains $@ which may have side effects. | side_effect.py:5:8:5:38 | Attribute() | an expression |

python/ql/test/query-tests/Statements/asserts/assert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ def assert_tuple(x, y):
1616
assert ()
1717
assert (x, y)
1818

19-
import subprocess
20-
assert subprocess.call(['run-backup']) == 0 # TODO: FN
19+
20+
2121

2222

2323

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# For now, this test lives in its own file, since including them in the top of assert.py
2+
# messes up the results of the refers-to/points-to analysis
3+
# see /home/rasmus/code/ql/python/ql/test/library-tests/PointsTo/regressions/subprocess-assert/mwe_failure.py
4+
import subprocess
5+
assert subprocess.call(['run-backup']) == 0

0 commit comments

Comments
 (0)