Skip to content

Commit ac5a46f

Browse files
committed
Python: split test as suggested in review
1 parent 5f4aad4 commit ac5a46f

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Add taintlib to PATH so it can be imported during runtime without any hassle
2+
import sys; import os; sys.path.append(os.path.dirname(os.path.dirname((__file__))))
3+
from taintlib import *
4+
5+
# This has no runtime impact, but allows autocomplete to work
6+
from typing import TYPE_CHECKING
7+
if TYPE_CHECKING:
8+
from ..taintlib import *
9+
10+
11+
# Actual tests
12+
13+
class Iter:
14+
def __iter__(self):
15+
return self
16+
17+
def __next__(self):
18+
raise StopIteration
19+
20+
def test_for():
21+
iter = Iter()
22+
taint(iter)
23+
for tainted in iter:
24+
ensure_tainted(tainted) # $ tainted
25+
26+
27+
28+
# Make tests runable
29+
30+
test_for()

python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep/test_syntax.py renamed to python/ql/test/experimental/dataflow/tainttracking/defaultAdditionalTaintStep/test_with.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,10 @@ def test_with_arg():
5151
with ctx as tainted:
5252
ensure_tainted(tainted) # $ tainted
5353

54-
class Iter:
55-
def __iter__(self):
56-
return self
57-
58-
def __next__(self):
59-
raise StopIteration
60-
61-
def test_for():
62-
iter = Iter()
63-
taint(iter)
64-
for tainted in iter:
65-
ensure_tainted(tainted) # $ tainted
66-
6754

6855

6956
# Make tests runable
7057

7158
test_with()
7259
test_with_taint()
7360
test_with_arg()
74-
test_for()

0 commit comments

Comments
 (0)