mirror of
https://github.com/github/codeql.git
synced 2025-12-20 02:44:30 +01:00
Python: iter str/seq query gives non-useful results with tests
This commit is contained in:
@@ -1 +1,3 @@
|
||||
| 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 |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# This example illustrates that all valid results are not useful.
|
||||
# The alert in this file should be suppressed (TODO).
|
||||
# see https://github.com/Semmle/ql/issues/3207
|
||||
|
||||
def foo(l):
|
||||
for (k, v) in l:
|
||||
print(k, v)
|
||||
|
||||
foo([('a', 42), ('b', 43)])
|
||||
|
||||
import unittest
|
||||
|
||||
class FooTest(unittest.TestCase):
|
||||
def test_valid(self):
|
||||
foo([('a', 42), ('b', 43)])
|
||||
|
||||
def test_not_valid(self):
|
||||
with six.assertRaises(self, ValueError):
|
||||
foo("not valid")
|
||||
Reference in New Issue
Block a user