virtual_fs: Fix bug with "rmdir" command.
In python3, if you removed a directory that files within it,
you would get an error saying "dictionary changed size
during iteration."
The fix is to list-ify the keys before iterating over them (and
popping keys from the dictionary).
MODIFY
zulip_bots/zulip_bots/bots/virtual_fs/test_virtual_fs.py
zulip_bots/zulip_bots/bots/virtual_fs/test_virtual_fs.py
@@ -36,7 +36,11 @@ class TestVirtualFsBot(BotTestCase):
("", self.help_txt),
("pwd", "foo@example.com:\n/"),
("cd /home", "foo@example.com:\nERROR: invalid path"),
+ ("mkdir etc", "foo@example.com:\ndirectory created"),
("mkdir home", "foo@example.com:\ndirectory created"),
("cd /home", "foo@example.com:\nCurrent path: /home/"),
+ ("mkdir steve", "foo@example.com:\ndirectory created"),
+ ("rmdir /home", "foo@example.com:\nremoved"),
+ ("ls", "foo@example.com:\nERROR: file does not exist"),
]
self.verify_dialog(expected)

MODIFY
zulip_bots/zulip_bots/bots/virtual_fs/virtual_fs.py
zulip_bots/zulip_bots/bots/virtual_fs/virtual_fs.py
@@ -252,7 +252,7 @@ def fs_rmdir(fs: Dict[str, Any], user: str, fn: str) -> Tuple[Dict[str, Any], An
new_fs.pop(path)
directory = get_directory(path)
new_fs[directory]['fns'].remove(path)
- for sub_path in new_fs.keys():
+ for sub_path in list(new_fs.keys()):
if sub_path.startswith(path+'/'):
new_fs.pop(sub_path)
msg = 'removed'

virtual_fs: Fix bug with "rmdir" command.

In python3, if you removed a directory that files within it,
you would get an error saying "dictionary changed size
during iteration."

The fix is to list-ify the keys before iterating over them (and
popping keys from the dictionary).