Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4bd5d5

Browse files
committed
add-test-for-exact-match
1 parent 1127641 commit c4bd5d5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

tests/test_completer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,9 +1481,14 @@ def __getattr__(self, attr):
14811481
sys.modules["my.unsafe.lib"] = unsafe_lib
14821482
exec(factory_code, unsafe_lib.__dict__)
14831483

1484+
fake_safe_lib = types.ModuleType("my_fake_lib")
1485+
sys.modules["my_fake_lib"] = fake_safe_lib
1486+
exec(factory_code, fake_safe_lib.__dict__)
1487+
14841488
ip = get_ipython()
14851489
ip.user_ns["safe_list_factory"] = safe_lib.ListFactory()
14861490
ip.user_ns["unsafe_list_factory"] = unsafe_lib.ListFactory()
1491+
ip.user_ns["fake_safe_factory"] = fake_safe_lib.ListFactory()
14871492
complete = ip.Completer.complete
14881493
with (
14891494
evaluation_policy("limited", allowed_getattr_external={"my.safe.lib"}),
@@ -1506,6 +1511,8 @@ def __getattr__(self, attr):
15061511
self.assertIn(".append", matches)
15071512
_, matches = complete(line_buffer="unsafe_list_factory.example.")
15081513
self.assertIn(".append", matches)
1514+
_, matches = complete(line_buffer="fake_safe_factory.example.")
1515+
self.assertNotIn(".append", matches)
15091516

15101517
with (
15111518
evaluation_policy("limited"),

0 commit comments

Comments
 (0)