Skip to content

Commit 94ccc16

Browse files
committed
Python: iter str/seq query gives non-useful results with tests
1 parent 46ecbef commit 94ccc16

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
| statements_test.py:21:5:21:19 | For | Iteration over $@, of class list, may also iterate over $@. | statements_test.py:20:13:20:33 | ControlFlowNode for List | sequence | statements_test.py:18:13:18:26 | ControlFlowNode for Str | string |
2+
| supress_uses_from_tests.py:6:5:6:20 | For | Iteration over $@, of class list, may also iterate over $@. | supress_uses_from_tests.py:9:5:9:26 | ControlFlowNode for List | sequence | supress_uses_from_tests.py:19:17:19:27 | ControlFlowNode for Str | string |
3+
| supress_uses_from_tests.py:6:5:6:20 | For | Iteration over $@, of class list, may also iterate over $@. | supress_uses_from_tests.py:15:13:15:34 | ControlFlowNode for List | sequence | supress_uses_from_tests.py:19:17:19:27 | ControlFlowNode for Str | string |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This example illustrates that all valid results are not useful.
2+
# The alert in this file should be suppressed (TODO).
3+
# see https://github.com/Semmle/ql/issues/3207
4+
5+
def foo(l):
6+
for (k, v) in l:
7+
print(k, v)
8+
9+
foo([('a', 42), ('b', 43)])
10+
11+
import unittest
12+
13+
class FooTest(unittest.TestCase):
14+
def test_valid(self):
15+
foo([('a', 42), ('b', 43)])
16+
17+
def test_not_valid(self):
18+
with six.assertRaises(self, ValueError):
19+
foo("not valid")

0 commit comments

Comments
 (0)