Skip to content

Commit cf7602d

Browse files
authored
Add test: handling multiple imports for url-sandbox (#745)
1 parent 8497fbd commit cf7602d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/codemods/test_url_sandbox.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,31 @@ def foo():
261261
"""
262262

263263
self.run_and_assert(tmpdir, input_code, expected)
264+
265+
@pytest.mark.xfail(
266+
reason="Does not properly handle 'from' imports with multiple names"
267+
)
268+
def test_multiple_imports(self, add_dependency, tmpdir):
269+
input_code = """
270+
from requests import Response, Timeout, get
271+
import csv
272+
273+
del Response, Timeout # just to make sure these names are used
274+
275+
url = input()
276+
get(url)
277+
csv.excel
278+
"""
279+
expected = """
280+
from requests import Response, Timeout
281+
import csv
282+
from security import safe_requests
283+
284+
del Response, Timeout # just to make sure these names are used
285+
286+
url = input()
287+
safe_requests.get(url)
288+
csv.excel
289+
"""
290+
self.run_and_assert(tmpdir, input_code, expected)
291+
add_dependency.assert_called_once_with(Security)

0 commit comments

Comments
 (0)