Skip to content

Commit bc49bc7

Browse files
committed
Python: Add variable with underscore to __all__ tests
1 parent 224d379 commit bc49bc7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

python/ql/test/library-tests/modules/__all__/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
print(" foo={!r}".format(foo))
1818
print(" bar={!r}".format(bar))
1919
print(" baz={!r}".format(baz))
20+
try:
21+
print(" _qux={!r}".format(_qux))
22+
except NameError:
23+
print(" _qux not imported")
2024
del foo, bar, baz
2125

2226
from all_list import *
@@ -82,3 +86,5 @@
8286
print(" foo={!r}".format(mod.foo))
8387
print(" bar={!r}".format(mod.bar))
8488
print(" baz={!r}".format(mod.baz))
89+
90+
print("\nspecial: no_all._qux={!r}".format(no_all._qux))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
foo = "foo"
22
bar = "bar"
33
baz = "baz"
4+
# When `__all__` is not defined, names starting with underscore is not imported with `from <module> import *`
5+
_qux = "qux"

0 commit comments

Comments
 (0)