()
| 196 | |
| 197 | |
| 198 | def test_custom_construct_commandsets() -> None: |
| 199 | command_set_b = CommandSetB("foo") |
| 200 | |
| 201 | # Verify that _cmd cannot be accessed until CommandSet is registered. |
| 202 | with pytest.raises(CommandSetRegistrationError) as excinfo: |
| 203 | command_set_b._cmd.poutput("test") |
| 204 | assert "is not registered" in str(excinfo.value) |
| 205 | |
| 206 | # Verifies that a custom initialized CommandSet loads correctly when passed into the constructor |
| 207 | app = WithCommandSets(command_sets=[command_set_b]) |
| 208 | |
| 209 | cmds_cats, _help_topics = app._build_command_info() |
| 210 | assert "Command Set B" in cmds_cats |
| 211 | |
| 212 | # Verifies that the same CommandSet cannot be loaded twice |
| 213 | command_set_2 = CommandSetB("bar") |
| 214 | with pytest.raises(CommandSetRegistrationError): |
| 215 | assert app.register_command_set(command_set_2) |
| 216 | |
| 217 | # Verify that autoload doesn't conflict with a manually loaded CommandSet that could be autoloaded. |
| 218 | command_set_a = CommandSetA() |
| 219 | app2 = WithCommandSets(command_sets=[command_set_a]) |
| 220 | |
| 221 | with pytest.raises(CommandSetRegistrationError): |
| 222 | app2.register_command_set(command_set_b) |
| 223 | |
| 224 | app.unregister_command_set(command_set_b) |
| 225 | |
| 226 | app2.register_command_set(command_set_b) |
| 227 | |
| 228 | assert hasattr(app2, "do_apple") |
| 229 | assert hasattr(app2, "do_aardvark") |
| 230 | |
| 231 | assert app2.find_commandset_for_command("aardvark") is command_set_b |
| 232 | assert app2.find_commandset_for_command("apple") is command_set_a |
| 233 | |
| 234 | matches = app2.find_commandsets(CommandSetBase, subclass_match=True) |
| 235 | assert command_set_a in matches |
| 236 | assert command_set_b in matches |
| 237 | assert command_set_2 not in matches |
| 238 | |
| 239 | |
| 240 | def test_load_commands(manual_command_sets_app, capsys) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…