MCPcopy Create free account
hub / github.com/pyinvoke/invoke / base_case

Method base_case

integration/context.py:7–19  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5class Context_:
6 class sudo:
7 def base_case(self) -> None:
8 c = Context()
9 # Grab CI-oriented sudo user/pass direct from invocations.ci
10 # TODO: might be nice to give Collection a way to get a Config
11 # object direct, instead of a dict?
12 ci_conf = Config(ci_mod.ns.configuration()).ci.sudo
13 user = ci_conf.user
14 c.config.sudo.password = ci_conf.password
15 # Safety 1: ensure configured user even exists
16 assert c.run("id {}".format(user), warn=True)
17 # Safety 2: make sure we ARE them (and not eg root already)
18 assert c.run("whoami", hide=True).stdout.strip() == user
19 assert c.sudo("whoami", hide=True).stdout.strip() == "root"

Callers

nothing calls this directly

Calls 5

runMethod · 0.95
sudoMethod · 0.95
ContextClass · 0.90
ConfigClass · 0.90
configurationMethod · 0.80

Tested by

no test coverage detected