This exercises code in with_argparser() decorator that calls namespace providers
()
| 1222 | |
| 1223 | |
| 1224 | def test_ns_provider() -> None: |
| 1225 | """This exercises code in with_argparser() decorator that calls namespace providers""" |
| 1226 | ns_provider_set = NsProviderSet(1) |
| 1227 | app = NsProviderApp(auto_load_commands=False) |
| 1228 | |
| 1229 | # First test the case in which a namespace provider function resides in a CommandSet class which is registered. |
| 1230 | # with_argparser() will pass the CommandSet instance to the ns_provider() function. |
| 1231 | app.register_command_set(ns_provider_set) |
| 1232 | run_cmd(app, "test_ns") |
| 1233 | assert app.last_result == ns_provider_set |
| 1234 | |
| 1235 | # Now test the case in which a namespace provider function resides in a CommandSet class which is not registered. |
| 1236 | # with_argparser() will receive None from cmd2.Cmd._resolve_func_self() and therefore pass app as self to ns_provider(). |
| 1237 | app.unregister_command_set(ns_provider_set) |
| 1238 | run_cmd(app, "test_ns") |
| 1239 | assert app.last_result == app |
nothing calls this directly
no test coverage detected
searching dependent graphs…