Python: Add testcases for py/import-own-module

You can try out:

python2 -c "import pkg_ok; print(pkg_ok.foo1); print(pkg_ok.foo2); print(pkg_ok.foo3); print(pkg_ok.foo4); print(pkg_ok.foo5); print(pkg_ok.Foo3); print(pkg_ok.Foo5); print(pkg_ok.pkg_ok)"

python3 -c "import pkg_ok; print(pkg_ok.foo1); print(pkg_ok.foo2); print(pkg_ok.foo3); print(pkg_ok.foo4); print(pkg_ok.foo5); print(pkg_ok.Foo3); print(pkg_ok.Foo5); print(pkg_ok.pkg_ok)"
This commit is contained in:
Rasmus Wriedt Larsen
2020-02-10 11:29:30 +01:00
parent 90f94e2e54
commit 2bffbf0734
10 changed files with 37 additions and 0 deletions

View File

@@ -1 +1,2 @@
| imports_test.py:4:1:4:19 | Import | Module 'test_module2' is imported with both 'import' and 'import from' |
| pkg_notok/__init__.py:4:1:4:16 | Import | Module 'pkg_notok' is imported with both 'import' and 'import from' |

View File

@@ -1 +1,9 @@
| imports_test.py:8:1:8:19 | Import | The module 'imports_test' imports itself. |
| pkg_notok/__init__.py:4:1:4:16 | Import | The module 'pkg_notok' imports itself. |
| pkg_notok/__init__.py:6:1:6:25 | Import | The module 'pkg_notok' imports itself. |
| pkg_notok/__init__.py:7:1:7:37 | Import | The module 'pkg_notok' imports itself. |
| pkg_ok/__init__.py:2:1:2:18 | Import | The module 'pkg_ok' imports itself. |
| pkg_ok/__init__.py:4:1:4:23 | Import | The module 'pkg_ok' imports itself. |
| pkg_ok/__init__.py:5:1:5:28 | Import | The module 'pkg_ok' imports itself. |
| pkg_ok/__init__.py:7:1:7:18 | Import | The module 'pkg_ok' imports itself. |
| pkg_ok/__init__.py:8:1:8:22 | Import | The module 'pkg_ok' imports itself. |

View File

@@ -7,3 +7,5 @@ from test_module2 import func
#Module imports itself
import imports_test
import pkg_ok
import pkg_notok

View File

@@ -0,0 +1,8 @@
class Foo(object):
pass
import pkg_notok
from pkg_notok import Foo
from pkg_notok import Foo as NotOkFoo
from pkg_notok import * # TODO: TN

View File

@@ -0,0 +1,8 @@
# This import makes `pkg_ok` available, but also `foo1` (surprising as it may be)
import pkg_ok.foo1 # TODO: FP
from pkg_ok import foo2 # TODO: FP
from pkg_ok.foo3 import Foo3 # TODO: FP
from . import foo4 # TODO: FP
from .foo5 import Foo5 # TODO: FP

View File

@@ -0,0 +1,2 @@
class Foo1():
pass

View File

@@ -0,0 +1,2 @@
class Foo2():
pass

View File

@@ -0,0 +1,2 @@
class Foo3():
pass

View File

@@ -0,0 +1,2 @@
class Foo4():
pass

View File

@@ -0,0 +1,2 @@
class Foo5():
pass