Skip to content

Commit 95ac2c8

Browse files
committed
Python: Add another dynamic __all__ test
1 parent ab3edf3 commit 95ac2c8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
foo = "foo"
2+
bar = "bar"
3+
baz = "baz"
4+
5+
6+
temp = ["foo", "bar"]
7+
__all__ = temp

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@
4949
print(" baz not imported")
5050
del foo, bar
5151

52+
from all_dynamic2 import *
53+
print("all_dynamic2.py")
54+
print(" foo={!r}".format(foo))
55+
print(" bar={!r}".format(bar))
56+
try:
57+
print(" baz={!r}".format(baz))
58+
except NameError:
59+
print(" baz not imported")
60+
del foo, bar
5261

5362
# Example of wrong definition of `__all__`, where it is not a sequence.
5463
try:
@@ -65,9 +74,10 @@
6574
import all_list
6675
import all_tuple
6776
import all_dynamic
77+
import all_dynamic2
6878
import all_set
6979

70-
for mod in [no_all, all_list, all_tuple, all_dynamic, all_set]:
80+
for mod in [no_all, all_list, all_tuple, all_dynamic, all_dynamic2, all_set]:
7181
print("{}.py".format(mod.__name__))
7282
print(" foo={!r}".format(mod.foo))
7383
print(" bar={!r}".format(mod.bar))

0 commit comments

Comments
 (0)