Skip to content

Commit 1942288

Browse files
committed
Python: Add tests for py/import-deprecated-module
1 parent 5ab6457 commit 1942288

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
| test.py:5:1:5:13 | Import | The rfc822 module was deprecated in version 2.3. Use email module instead. |
2-
| test.py:6:1:6:16 | Import | The posixfile module was deprecated in version 1.5. Use email module instead. |
1+
| test.py:2:1:2:13 | Import | The rfc822 module was deprecated in version 2.3. Use email module instead. |
2+
| test.py:3:1:3:16 | Import | The posixfile module was deprecated in version 1.5. Use email module instead. |
3+
| test.py:6:1:6:18 | ClassDef | The md5 module was deprecated in version 2.5. Use hashlib module instead. |
4+
| test.py:7:5:7:18 | FunctionDef | The md5 module was deprecated in version 2.5. Use hashlib module instead. |
5+
| test.py:8:9:8:18 | Import | The md5 module was deprecated in version 2.5. Use hashlib module instead. |
6+
| test.py:14:5:14:23 | Import | The md5 module was deprecated in version 2.5. Use hashlib module instead. |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Imports/DeprecatedModule.ql
1+
Imports/DeprecatedModule.ql
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
2-
3-
4-
#Some deprecated modules
1+
# Some deprecated modules
52
import rfc822
63
import posixfile
4+
5+
# TODO: We should only report a bad import once
6+
class Foo(object):
7+
def foo(self):
8+
import md5
9+
10+
# TODO: Backwards compatible code, should not report
11+
try:
12+
from hashlib import md5
13+
except ImportError:
14+
from md5 import md5

0 commit comments

Comments
 (0)